]> git.eshelyaron.com Git - emacs.git/commitdiff
Prefer POSIX timers to timerfd timers
authorKen Brown <kbrown@cornell.edu>
Sun, 14 Nov 2021 15:30:44 +0000 (10:30 -0500)
committerKen Brown <kbrown@cornell.edu>
Sun, 14 Nov 2021 19:06:55 +0000 (14:06 -0500)
* src/atimer.c (set_alarm): Try to start a POSIX timer before
starting a timerfd timer.  On Cygwin, return if the POSIX timer is
started successfully. (Bug#51734)

src/atimer.c

index 9bde9c2446f5d304f30fe8927cb1cacc2314f934..df35603f32402a8d73309ee000b81f8457f44270 100644 (file)
@@ -309,24 +309,29 @@ set_alarm (void)
          struct itimerspec ispec;
          ispec.it_value = atimers->expiration;
          ispec.it_interval.tv_sec = ispec.it_interval.tv_nsec = 0;
+         if (alarm_timer_ok
+             && timer_settime (alarm_timer, TIMER_ABSTIME, &ispec, 0) == 0)
+           exit = true;
+
+         /* Don't start both timerfd and POSIX timers on Cygwin; this
+            causes a slowdown (bug#51734).  Prefer POSIX timers
+            because the timerfd notifications aren't delivered while
+            Emacs is busy, which prevents things like the hourglass
+            pointer from being displayed reliably (bug#19776). */
+# ifdef CYGWIN
+         if (exit)
+           return;
+# endif
+
 # ifdef HAVE_TIMERFD
-         if (timerfd_settime (timerfd, TFD_TIMER_ABSTIME, &ispec, 0) == 0)
+         if (0 <= timerfd
+             && timerfd_settime (timerfd, TFD_TIMER_ABSTIME, &ispec, 0) == 0)
            {
              add_timer_wait_descriptor (timerfd);
              exit = true;
            }
 # endif
 
-# ifdef CYGWIN
-         /* Don't start both timerfd and alarms on Cygwin; this
-            causes a slowdown (bug#51734). */
-         if (exit)
-           return;
-# endif
-         if (alarm_timer_ok
-             && timer_settime (alarm_timer, TIMER_ABSTIME, &ispec, 0) == 0)
-           exit = true;
-
          if (exit)
            return;
        }