summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-01-07 19:15:56 +0000
committerCarl Hetherington <cth@carlh.net>2014-01-07 19:15:56 +0000
commitc33e0fb07be8ffeeff4581aa07621aebd84c638a (patch)
tree6764f50930e19acdbc5fa22df604fd207e7827f4 /src/lib
parent16d5c07df7752d093df804d3f1141790f633c24b (diff)
More reliable updater wake-up.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/update.cc7
-rw-r--r--src/lib/update.h1
2 files changed, 7 insertions, 1 deletions
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;
};