From 78a953177397f3eb85cfee4398975e8519895e6b Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Mon, 14 Jan 2013 19:32:30 +0100 Subject: [PATCH] Fix a bug in timer loop Silly logic bug introduced in dda7de17e74d7e8 Timer thread, when msec = 0, instead of going to sleep, calls check_time() in an endless loop. Spotted and reported by snino64 due to abnormally high CPU usage. No functional change. --- src/thread.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/thread.cpp b/src/thread.cpp index bc0b3fcc..5f3b4d31 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -76,9 +76,10 @@ void TimerThread::idle_loop() { while (!do_exit) { mutex.lock(); - while (!msec && !do_exit) - sleepCondition.wait_for(mutex, msec ? msec : INT_MAX); + do sleepCondition.wait_for(mutex, msec ? msec : INT_MAX); + while (!msec && !do_exit); // Don't allow wakeups when msec = 0 mutex.unlock(); + check_time(); } } -- 2.39.2