From c33e0fb07be8ffeeff4581aa07621aebd84c638a Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 7 Jan 2014 19:15:56 +0000 Subject: [PATCH] More reliable updater wake-up. --- src/lib/update.cc | 7 ++++++- src/lib/update.h | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib/update.cc b/src/lib/update.cc index 6e5f92edc..a98ee5b5d 100644 --- a/src/lib/update.cc +++ b/src/lib/update.cc @@ -48,6 +48,7 @@ UpdateChecker::UpdateChecker () , _curl (0) , _state (NOT_RUN) , _emits (0) + , _to_do (0) { curl_global_init (CURL_GLOBAL_ALL); _curl = curl_easy_init (); @@ -76,6 +77,7 @@ void UpdateChecker::run () { boost::mutex::scoped_lock lm (_process_mutex); + _to_do++; _condition.notify_one (); } @@ -84,7 +86,10 @@ UpdateChecker::thread () { while (1) { boost::mutex::scoped_lock lock (_process_mutex); - _condition.wait (lock); + while (_to_do == 0) { + _condition.wait (lock); + } + --_to_do; lock.unlock (); try { diff --git a/src/lib/update.h b/src/lib/update.h index a1aefd0a1..c19173911 100644 --- a/src/lib/update.h +++ b/src/lib/update.h @@ -84,4 +84,5 @@ private: boost::thread* _thread; boost::mutex _process_mutex; boost::condition _condition; + int _to_do; }; -- 2.30.2