]> code.delx.au - gnu-emacs/blobdiff - src/atimer.c
* xterm.c (x_sync_with_move): Really wait 0.5s, not 0.0005s.
[gnu-emacs] / src / atimer.c
index 9079e7712e059685567866bfc31af35ecec045d0..c03ac96c6dac87a826a335540ecb4abcd68f6c66 100644 (file)
@@ -410,9 +410,19 @@ handle_alarm_signal (int sig)
 
 #ifdef HAVE_TIMERFD
 
+/* Called from wait_reading_process_output when FD, which
+   should be equal to TIMERFD, is available for reading.  */
+
 void
 timerfd_callback (int fd, void *arg)
 {
+  char buf[8];
+  ptrdiff_t nbytes;
+
+  eassert (fd == timerfd);
+  nbytes = emacs_read (fd, buf, sizeof (buf));
+  /* Just discard an expiration count for now.  */
+  eassert (nbytes == sizeof (buf));
   do_pending_atimers ();
 }
 
@@ -442,7 +452,18 @@ turn_on_atimers (bool on)
   if (on)
     set_alarm ();
   else
-    alarm (0);
+    {
+#ifdef HAVE_TIMERFD
+      if (special_timer_available > 1)
+       {
+         struct itimerspec ispec;
+         memset (&ispec, 0, sizeof (ispec));
+         /* Writing zero expiration time should disarm it.  */
+         timerfd_settime (timerfd, TFD_TIMER_ABSTIME, &ispec, 0);
+       }
+#endif /* HAVE_TIMERFD */
+      alarm (0);
+    }
 }
 
 /* This is intended to use from automated tests.  */