From a395e3577f1f187aca0b3c412d3607748bdd95a8 Mon Sep 17 00:00:00 2001 From: Peter Johnson Date: Thu, 13 Aug 2015 21:34:03 -0700 Subject: [PATCH] Notifier: Fix condition variable race. --- src/Notifier.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Notifier.cpp b/src/Notifier.cpp index cba61c6f8f..c4c65db3bb 100644 --- a/src/Notifier.cpp +++ b/src/Notifier.cpp @@ -36,8 +36,10 @@ void Notifier::Stop() { void Notifier::ThreadMain() { std::unique_lock lock(m_mutex); while (m_active) { - m_cond.wait(lock); - if (!m_active) continue; + while (m_entry_notifications.empty() && m_conn_notifications.empty()) { + m_cond.wait(lock); + if (!m_active) return; + } // Entry notifications while (!m_entry_notifications.empty()) {