From 848746862caf337254a8a3e3a6bd3fa355db4fc8 Mon Sep 17 00:00:00 2001 From: Vladimir Makhnychev Date: Fri, 22 Feb 2013 00:00:00 +0000 Subject: [PATCH] CondVar::SignalAll was broken, leading to deadlocks on Windows builds. http://code.google.com/p/leveldb/issues/detail?id=149 --- port/port_win.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/port/port_win.cc b/port/port_win.cc index 99c1d8e3460dd..1b0f060a19caa 100644 --- a/port/port_win.cc +++ b/port/port_win.cc @@ -109,12 +109,10 @@ void CondVar::Signal() { void CondVar::SignalAll() { wait_mtx_.Lock(); - for(long i = 0; i < waiting_; ++i) { - ::ReleaseSemaphore(sem1_, 1, NULL); - while(waiting_ > 0) { - --waiting_; - ::WaitForSingleObject(sem2_, INFINITE); - } + ::ReleaseSemaphore(sem1_, waiting_, NULL); + while(waiting_ > 0) { + --waiting_; + ::WaitForSingleObject(sem2_, INFINITE); } wait_mtx_.Unlock(); }