OSDN Git Service

STPK-1429: Always wait for at least 1 ms before repeating samples
authorPatrick Porlan <patrick.porlan@intel.com>
Fri, 8 Aug 2014 14:45:26 +0000 (16:45 +0200)
committerAdriana Reus <adriana.reus@intel.com>
Wed, 13 Aug 2014 15:23:54 +0000 (18:23 +0300)
Auto-repetition of events at very high sample rates can make the
device unresponsive.

Issue: STPK-1429

Change-Id: Id846f7a8e313b96099e78fbb0e53a93ca6d194f2
Signed-off-by: Patrick Porlan <patrick.porlan@intel.com>
control.c

index 8a4725c..90bfde9 100644 (file)
--- a/control.c
+++ b/control.c
@@ -838,9 +838,14 @@ static int get_poll_wait_timeout (void)
 
        ms_to_wait = (target_ts - get_timestamp()) / 1000000;
 
-       /* If the target timestamp is already behind us, don't wait */
-       if (ms_to_wait < 1)
-               return 0;
+       /*
+        * If the target timestamp is very close or already behind us, wait
+        * nonetheless for a millisecond in order to a) avoid busy loops, and
+        * b) give a chance for the driver to report data before we repeat the
+        * last received sample.
+        */
+       if (ms_to_wait <= 0)
+               return 1;
 
        return ms_to_wait;
 }