cec: fixed possible deadlock because of a negative timeout in CAdapterCommunication...
authorLars Op den Kamp <lars@opdenkamp.eu>
Wed, 25 Jan 2012 15:45:31 +0000 (16:45 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Wed, 25 Jan 2012 15:45:31 +0000 (16:45 +0100)
src/lib/adapter/AdapterCommunication.cpp

index e143b08c3f9054e2a0e5b307df9e1600c4331c59..77c90326377b4832d5b40ca0c80f0a8f9fb0a1cb 100644 (file)
@@ -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;