From 4d0f02a46aab4f2e071638f656343aa8a716d3fb Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Thu, 16 May 2013 23:01:24 -0700 Subject: [PATCH] CondVar::SignalAll was broken, leading to deadlocks on Windows builds. http://code.google.com/p/leveldb/issues/detail?id=149 --- src/cpp/leveldb/port/port_win.cc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/cpp/leveldb/port/port_win.cc b/src/cpp/leveldb/port/port_win.cc index 99c1d8e346..1b0f060a19 100644 --- a/src/cpp/leveldb/port/port_win.cc +++ b/src/cpp/leveldb/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(); }