[PATCH libinput] timer: drain data on the timerfd when it triggers

Peter Hutterer peter.hutterer at who-t.net
Wed Apr 29 18:33:02 PDT 2015

Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
I admit, I'm not sure of the effect it has leaving the data sitting there.
timerfd_create states that only the value read changes, not the actual size
of the data (which I couldn't reproduce in a quick test, it's always 1)
epoll sounds like it should keep triggering as long as data is sitting there
but it doesn't. Didn't have time to investigate further, so here's the patch
for what seems to be the correct thing to do.

 src/timer.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/timer.c b/src/timer.c
index f6c8e42..285f75b 100644
--- a/src/timer.c
+++ b/src/timer.c
@@ -101,6 +101,9 @@ libinput_timer_handler(void *data)
 	struct libinput *libinput = data;
 	struct libinput_timer *timer, *tmp;
 	uint64_t now;
+	uint64_t discard;
+	read(libinput->timer.fd, &discard, sizeof(discard));
 	now = libinput_now(libinput);
 	if (now == 0)

More information about the wayland-devel mailing list