issue #2305: Fixing a bug that passing wrong mutex parameter to "wait".

This commit is contained in:
James Chen 2013-06-26 11:06:13 +08:00
parent f2ab73c533
commit 3ad11cc63a
1 changed files with 8 additions and 7 deletions

View File

@ -104,13 +104,14 @@ static void networkThread(void)
// step 1: send http request if the requestQueue isn't empty // step 1: send http request if the requestQueue isn't empty
request = NULL; request = NULL;
{ s_requestQueueMutex.lock();
std::unique_lock<std::mutex> lk(s_requestQueueMutex); //Get request task from queue request = dynamic_cast<HttpRequest*>(s_requestQueue->objectAtIndex(0));
s_SleepCondition.wait(lk, []{ return 0 != s_requestQueue->count(); }); s_requestQueue->removeObjectAtIndex(0);
s_requestQueueMutex.unlock();
request = dynamic_cast<HttpRequest*>(s_requestQueue->objectAtIndex(0));
s_requestQueue->removeObjectAtIndex(0); std::unique_lock<std::mutex> lk(s_SleepMutex); //Get request task from queue
} s_SleepCondition.wait(lk, []{ return 0 != s_requestQueue->count(); });
// step 2: libcurl sync access // step 2: libcurl sync access