summaryrefslogtreecommitdiff
path: root/src/atimer.c
diff options
context:
space:
mode:
authorKen Brown <kbrown@cornell.edu>2021-11-14 10:30:44 -0500
committerKen Brown <kbrown@cornell.edu>2021-11-14 14:06:55 -0500
commit364cf2494c9b94e1d265b637394c80c4eecfb505 (patch)
tree735ccb17b7d6952546e6fe049455acca7a98a460 /src/atimer.c
parente6df5a32d07564115488643206396ba0c28decf2 (diff)
downloademacs-364cf2494c9b94e1d265b637394c80c4eecfb505.tar.gz
Prefer POSIX timers to timerfd timers
* 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)
Diffstat (limited to 'src/atimer.c')
-rw-r--r--src/atimer.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/atimer.c b/src/atimer.c
index 9bde9c2446f..df35603f324 100644
--- a/src/atimer.c
+++ b/src/atimer.c
@@ -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;
}