From: Lars Op den Kamp Date: Wed, 25 Jan 2012 15:45:31 +0000 (+0100) Subject: cec: fixed possible deadlock because of a negative timeout in CAdapterCommunication... X-Git-Tag: upstream/2.2.0~1^2~39^2~7 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=e2800c154cf5ce325adf02f7473ce4686962f383;p=deb_libcec.git cec: fixed possible deadlock because of a negative timeout in CAdapterCommunication::WaitForTransmitSucceeded() --- diff --git a/src/lib/adapter/AdapterCommunication.cpp b/src/lib/adapter/AdapterCommunication.cpp index e143b08..77c9032 100644 --- a/src/lib/adapter/AdapterCommunication.cpp +++ b/src/lib/adapter/AdapterCommunication.cpp @@ -374,8 +374,11 @@ bool CAdapterCommunication::WaitForTransmitSucceeded(CCECAdapterMessage *message while (!bTransmitSucceeded && !bError && (message->transmit_timeout == 0 || iNow < iTargetTime)) { CCECAdapterMessage msg; + int32_t iWait = (int32_t)(iTargetTime - iNow); + if (iWait <= 5 || message->transmit_timeout <= 5) + iWait = CEC_DEFAULT_TRANSMIT_WAIT; - if (!Read(msg, message->transmit_timeout > 0 ? (int32_t)(iTargetTime - iNow) : 1000)) + if (!Read(msg, iWait)) { iNow = GetTimeMs(); continue;