We are migrating issue tracker of Cocos2d-x Project to Github, please create new issue there. Thanks.
CCHttpClient -- halts when called destroyInstance() and then created again. Cocos2d-x 2.1
CCHttpClient -- halts when called destroyInstance() and then created again. Cocos2d-x 2.1
Bug #3986 [Closed]
See pull request here: https://github.com/cocos2d/cocos2d-x/pull/5682
Change
this:
bool CCHttpClient::lazyInitThreadSemphore() { if (s_requestQueue != NULL) { return true; } else { s_requestQueue = new CCArray(); s_requestQueue->init(); s_responseQueue = new CCArray(); s_responseQueue->init(); s_progressResponseQueue = new CCArray(); s_progressResponseQueue->init(); pthread_mutex_init(&s_requestQueueMutex, NULL); pthread_mutex_init(&s_responseQueueMutex, NULL); pthread_mutex_init(&s_progressResponseQueueMutex, NULL); pthread_mutex_init(&s_SleepMutex, NULL); pthread_cond_init(&s_SleepCondition, NULL); need_quit = false; pthread_create(&s_networkThread, NULL, networkThread, NULL); pthread_detach(s_networkThread); } return true; }
to this:
bool CCHttpClient::lazyInitThreadSemphore() { if (s_requestQueue != NULL) { return true; } else { s_requestQueue = new CCArray(); s_requestQueue->init(); s_responseQueue = new CCArray(); s_responseQueue->init(); s_progressResponseQueue = new CCArray(); s_progressResponseQueue->init(); pthread_mutex_init(&s_requestQueueMutex, NULL); pthread_mutex_init(&s_responseQueueMutex, NULL); pthread_mutex_init(&s_progressResponseQueueMutex, NULL); pthread_mutex_init(&s_SleepMutex, NULL); pthread_cond_init(&s_SleepCondition, NULL); pthread_create(&s_networkThread, NULL, networkThread, NULL); pthread_detach(s_networkThread); need_quit = false; } return true; }
Redmine issue system is closed, we are using github issue system instead.
This issue was moved to https://github.com/cocos2d/cocos2d-x/issues/8337
Status: | Closed | |
---|---|---|
Start date: | 2014-02-10 | |
Priority: | Low | |
Due date: | ||
Assignee: | - | |
% Done: | 0% |
|
Category: | - | |
Target version: | - |
Appears on iOS and Android.
Create and use CCHttpClient:
CCHttpRequest *request = new CCHttpRequest();
request->setUrl(URL);
request->setRequestType(CCHttpRequest::kHttpDownload);
request->setResponseCallback(this, httpresponse_selector(UnitMapScene::downloadCompleted));
request->setDownloadPath(destination);
CCHttpClient *sharedClient = CCHttpClient::getInstance();
sharedClient->setTimeoutForConnect(1);
sharedClient->setTimeoutForRead(3600);
sharedClient->send(request);
destroy the instance when download is ready
CCHttpClient *sharedClient = CCHttpClient::getInstance();
sharedClient->destroyInstance();
Do #1 again:
Application freezes:
EXC_BAD_ACCESS ( s_requestQueue is NULL)
HttpClient.cpp line 462: s_requestQueue->addObject(request);
Version 2.1