[BRLTTY] Virtual driver is not reading the socket

Dave Mielke dave at mielke.cc
Wed May 11 21:38:38 EDT 2016


[quoted lines by Jaroslav Skarvada on 2016/05/11 at 12:42 -0400]

>Hmm, for me the control flow reaches asyncAwaitCondition and then immediately exits
>due to the timeout. Maybe there is another/different problem.

You're correct. I didn't look closely enough. The timeout test shouldn't be 
done on the first iteration. Please test the attached patch 
(async-wait-1.patch).

-- 
Dave Mielke           | 2213 Fox Crescent | The Bible is the very Word of God.
Phone: 1-613-726-0014 | Ottawa, Ontario   | http://Mielke.cc/bible/
EMail: Dave at Mielke.cc | Canada  K2A 1H7   | http://FamilyRadio.org/
-------------- next part --------------
diff --git a/Programs/async_wait.c b/Programs/async_wait.c
index 231a07c..71b1372 100644
--- a/Programs/async_wait.c
+++ b/Programs/async_wait.c
@@ -142,13 +142,20 @@ awaitAction (long int timeout) {
 
 int
 asyncAwaitCondition (int timeout, AsyncConditionTester *testCondition, void *data) {
+  int first = 1;
   TimePeriod period;
   startTimePeriod(&period, timeout);
 
   while (!(testCondition && testCondition(data))) {
     long int elapsed;
 
-    if (afterTimePeriod(&period, &elapsed)) return 0;
+    if (first) {
+      first = 0;
+      elapsed = 0;
+    } else if (afterTimePeriod(&period, &elapsed)) {
+      return 0;
+    }
+
     awaitAction(timeout - elapsed);
   }
 


More information about the BRLTTY mailing list