aboutsummaryrefslogtreecommitdiffstats
path: root/src/atimer.c
diff options
context:
space:
mode:
authorEli Zaretskii2015-06-22 19:11:45 +0300
committerEli Zaretskii2015-06-22 19:11:45 +0300
commitc4c531bbee86f45a18b2af168f705a3e53aa7327 (patch)
treea1127582b2e5a62590934d9586b58468875272b5 /src/atimer.c
parentfff0184e38342deedafd2ab0db7b51c692f461c7 (diff)
downloademacs-c4c531bbee86f45a18b2af168f705a3e53aa7327.tar.gz
emacs-c4c531bbee86f45a18b2af168f705a3e53aa7327.zip
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.
Diffstat (limited to 'src/atimer.c')
-rw-r--r--src/atimer.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/atimer.c b/src/atimer.c
index 8ff9bb89757..8a1a48be641 100644
--- a/src/atimer.c
+++ b/src/atimer.c
@@ -492,9 +492,9 @@ debug_timer_callback (struct atimer *t)
492 { 492 {
493#ifdef HAVE_SETITIMER 493#ifdef HAVE_SETITIMER
494 struct timespec delta = timespec_sub (now, r->expected); 494 struct timespec delta = timespec_sub (now, r->expected);
495 /* Too late if later than expected + 0.01s. FIXME: 495 /* Too late if later than expected + 0.02s. FIXME:
496 this should depend from system clock resolution. */ 496 this should depend from system clock resolution. */
497 if (timespec_cmp (delta, make_timespec (0, 10000000)) > 0) 497 if (timespec_cmp (delta, make_timespec (0, 20000000)) > 0)
498 r->intime = 0; 498 r->intime = 0;
499 else 499 else
500#endif /* HAVE_SETITIMER */ 500#endif /* HAVE_SETITIMER */
@@ -523,8 +523,26 @@ Return t if all self-tests are passed, nil otherwise. */)
523 debug_timer_callback, results[i]); 523 debug_timer_callback, results[i]);
524 } 524 }
525 525
526#ifdef HAVE_TIMERFD
526 /* Wait for 1s but process timers. */ 527 /* Wait for 1s but process timers. */
527 wait_reading_process_output (1, 0, 0, false, Qnil, NULL, 0); 528 wait_reading_process_output (1, 0, 0, false, Qnil, NULL, 0);
529#else
530 /* If timerfd is not supported, wait_reading_process_output won't
531 pay attention to timers that expired, and the callbacks won't be
532 called. So we need to run the expired timers' callbacks by
533 hand. */
534 /* Wait 1.2 sec for the timers to expire. */
535 struct timespec tend =
536 timespec_add (current_timespec (), make_timespec (1, 200000000));
537
538 while (timespec_cmp (current_timespec (), tend) < 0)
539 {
540 /* Wait for 5 msec between iterations. */
541 wait_reading_process_output (0, 5000000, 0, false, Qnil, NULL, 0);
542 if (pending_signals)
543 do_pending_atimers ();
544 }
545#endif
528 /* Shut up the compiler by "using" this variable. */ 546 /* Shut up the compiler by "using" this variable. */
529 (void) timer; 547 (void) timer;
530 548