Skip to content

Commit 5b81303

Browse files
tryfinallyJohnSully
authored andcommitted
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.
1 parent ede524c commit 5b81303

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/ae.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ int aeCreateRemoteFileEvent(aeEventLoop *eventLoop, int fd, int mask,
258258

259259
if (fSynchronous)
260260
{
261-
std::unique_lock<std::mutex> ulock(cmd.pctl->mutexcv, std::defer_lock);
261+
std::unique_lock<std::mutex> ulock(cmd.pctl->mutexcv);
262262
cmd.pctl->cv.wait(ulock);
263263
ret = cmd.pctl->rval;
264264
delete cmd.pctl;
@@ -311,7 +311,7 @@ int aePostFunction(aeEventLoop *eventLoop, std::function<void()> fn, bool fSynch
311311
int ret = AE_OK;
312312
if (fSynchronous)
313313
{
314-
std::unique_lock<std::mutex> ulock(cmd.pctl->mutexcv, std::defer_lock);
314+
std::unique_lock<std::mutex> ulock(cmd.pctl->mutexcv);
315315
cmd.pctl->cv.wait(ulock);
316316
ret = cmd.pctl->rval;
317317
delete cmd.pctl;

0 commit comments

Comments
 (0)