From: Peter Hutterer Date: Thu, 30 Apr 2015 23:09:38 +0000 (+1000) Subject: timer: set O_NONBLOCK on the timerfd X-Git-Tag: 0.15.0~14 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c2ef1854d82ebd6f484c59759f69dd30b4b3593b;p=platform%2Fupstream%2Flibinput.git timer: set O_NONBLOCK on the timerfd Resetting a timerfd empties the data on the fd, so if the timer is reset between triggering and us reading it, we may block trying to read it. Since we read events off a device in a loop, a device sending a continuous flow of events may cause the timer to trigger but delay reading it. If one of the events cause e.g. the tap timer to be set, the timerfd may be empty at the time of reading. Suggested-by: Derek Foreman Signed-off-by: Peter Hutterer --- diff --git a/src/timer.c b/src/timer.c index 285f75b2..114a6496 100644 --- a/src/timer.c +++ b/src/timer.c @@ -122,7 +122,8 @@ libinput_timer_handler(void *data) int libinput_timer_subsys_init(struct libinput *libinput) { - libinput->timer.fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC); + libinput->timer.fd = timerfd_create(CLOCK_MONOTONIC, + TFD_CLOEXEC | TFD_NONBLOCK); if (libinput->timer.fd < 0) return -1;