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()).
This commit is contained in:
parent
c133fc4836
commit
e05a0cd92c
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user