From: Lars Op den Kamp Date: Fri, 17 Feb 2012 01:58:48 +0000 (+0100) Subject: platform: fixed return value from CCondition::Wait() X-Git-Tag: upstream/2.2.0~1^2~35^2~19 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=44d840e6c4a08663017e0c2e265879825b549828;p=deb_libcec.git platform: fixed return value from CCondition::Wait() --- diff --git a/src/lib/platform/threads/mutex.h b/src/lib/platform/threads/mutex.h index 5a9ae13..6bd126e 100644 --- a/src/lib/platform/threads/mutex.h +++ b/src/lib/platform/threads/mutex.h @@ -257,18 +257,19 @@ namespace PLATFORM if (iTimeout == 0) return Wait(mutex, predicate); - bool bReturn(true); - if (!predicate) + if (predicate) + return true; + + bool bReturn(false); + bool bBreak(false); + CTimeout timeout(iTimeout); + uint32_t iMsLeft(0); + + while (!bReturn && !bBreak) { - CTimeout timeout(iTimeout); - uint32_t iMsLeft(0); - bReturn = false; - while (!bReturn) - { - iMsLeft = timeout.TimeLeft(); - if ((bReturn = iMsLeft == 0 || predicate) == false) - m_condition.Wait(mutex.m_mutex, iMsLeft); - } + iMsLeft = timeout.TimeLeft(); + if ((bReturn = predicate) == false && (bBreak = iMsLeft == 0) == false) + m_condition.Wait(mutex.m_mutex, iMsLeft); } return bReturn; }