Fix bug in condition_variabe.wait usage
consition variable wait should always be called with a locked mutex. This code break the pre-conditions of using wait. Former-commit-id: 5b81303f04580010f043e518a109b43971a63054
This commit is contained in:
parent
e25ec37484
commit
63bb6cb419
@ -258,7 +258,7 @@ int aeCreateRemoteFileEvent(aeEventLoop *eventLoop, int fd, int mask,
|
||||
|
||||
if (fSynchronous)
|
||||
{
|
||||
std::unique_lock<std::mutex> ulock(cmd.pctl->mutexcv, std::defer_lock);
|
||||
std::unique_lock<std::mutex> ulock(cmd.pctl->mutexcv);
|
||||
cmd.pctl->cv.wait(ulock);
|
||||
ret = cmd.pctl->rval;
|
||||
delete cmd.pctl;
|
||||
@ -311,7 +311,7 @@ int aePostFunction(aeEventLoop *eventLoop, std::function<void()> fn, bool fSynch
|
||||
int ret = AE_OK;
|
||||
if (fSynchronous)
|
||||
{
|
||||
std::unique_lock<std::mutex> ulock(cmd.pctl->mutexcv, std::defer_lock);
|
||||
std::unique_lock<std::mutex> ulock(cmd.pctl->mutexcv);
|
||||
cmd.pctl->cv.wait(ulock);
|
||||
ret = cmd.pctl->rval;
|
||||
delete cmd.pctl;
|
||||
|
Loading…
x
Reference in New Issue
Block a user