diff options
author | David Herrmann <dh.herrmann@gmail.com> | 2013-10-15 14:29:56 +0200 |
---|---|---|
committer | Kristian Høgsberg <krh@bitplanet.net> | 2013-10-21 14:09:02 -0700 |
commit | 36b8d9d44b8eadf69c7a227bd75d5de4b2f10aaa (patch) | |
tree | bd06be573698379b4c07738bed80137cb01a2a7c | |
parent | b1e63af8ea1babd51648710cd5ea02ba10d4b4c7 (diff) |
evdev: release devices on read() error
If read() fails without EAGAIN/EINTR, the device is very likely dead.
However, we must not remove the device as it might be muted/revoked. So we
simply remove the event-source to avoid polling the device and simply wait
for the udev-remove signal now.
Note that we cannot call evdev_device_destroy() as the caller created the
FD and might need custom code to close it (like weston_launcher_close()).
-rw-r--r-- | src/evdev.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/evdev.c b/src/evdev.c index edea3968..7397ea1d 100644 --- a/src/evdev.c +++ b/src/evdev.c @@ -22,6 +22,7 @@ #include "config.h" +#include <errno.h> #include <stdlib.h> #include <string.h> #include <linux/input.h> @@ -414,7 +415,13 @@ evdev_device_data(int fd, uint32_t mask, void *data) len = read(fd, &ev, sizeof ev); if (len < 0 || len % sizeof ev[0] != 0) { - /* FIXME: call evdev_device_destroy when errno is ENODEV. */ + if (len < 0 && errno != EAGAIN && errno != EINTR) { + weston_log("device %s died\n", + device->devnode); + wl_event_source_remove(device->source); + device->source = NULL; + } + return 1; } |