emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master c4c531b: Fix debug-timer-check on systems without H


From: Eli Zaretskii
Subject: [Emacs-diffs] master c4c531b: Fix debug-timer-check on systems without HAVE_TIMERFD
Date: Mon, 22 Jun 2015 16:13:36 +0000

branch: master
commit c4c531bbee86f45a18b2af168f705a3e53aa7327
Author: Eli Zaretskii <address@hidden>
Commit: Eli Zaretskii <address@hidden>

    Fix debug-timer-check on systems without HAVE_TIMERFD
    
    * src/atimer.c (Fdebug_timer_check) [!HAVE_TIMERFD]: Actively run
    the expired timers, since wait_reading_process_output doesn't.
    (debug_timer_callback): Enlarge the tolerance to 20 msec.
---
 src/atimer.c |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/atimer.c b/src/atimer.c
index 8ff9bb8..8a1a48b 100644
--- a/src/atimer.c
+++ b/src/atimer.c
@@ -492,9 +492,9 @@ debug_timer_callback (struct atimer *t)
     {
 #ifdef HAVE_SETITIMER
       struct timespec delta = timespec_sub (now, r->expected);
-      /* Too late if later than expected + 0.01s.  FIXME:
+      /* Too late if later than expected + 0.02s.  FIXME:
         this should depend from system clock resolution.  */
-      if (timespec_cmp (delta, make_timespec (0, 10000000)) > 0)
+      if (timespec_cmp (delta, make_timespec (0, 20000000)) > 0)
        r->intime = 0;
       else
 #endif /* HAVE_SETITIMER */
@@ -523,8 +523,26 @@ Return t if all self-tests are passed, nil otherwise.  */)
                            debug_timer_callback, results[i]);
     }
 
+#ifdef HAVE_TIMERFD
   /* Wait for 1s but process timers.  */
   wait_reading_process_output (1, 0, 0, false, Qnil, NULL, 0);
+#else
+  /* If timerfd is not supported, wait_reading_process_output won't
+     pay attention to timers that expired, and the callbacks won't be
+     called.  So we need to run the expired timers' callbacks by
+     hand.  */
+  /* Wait 1.2 sec for the timers to expire.  */
+  struct timespec tend =
+    timespec_add (current_timespec (), make_timespec (1, 200000000));
+
+  while (timespec_cmp (current_timespec (), tend) < 0)
+    {
+      /* Wait for 5 msec between iterations.  */
+      wait_reading_process_output (0, 5000000, 0, false, Qnil, NULL, 0);
+      if (pending_signals)
+       do_pending_atimers ();
+    }
+#endif
   /* Shut up the compiler by "using" this variable.  */
   (void) timer;
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]