mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-25 01:10:08 +01:00
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
d4c9c6b83b
commit
b98d0b9d89
1 changed files with 8 additions and 1 deletions
|
|
@ -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…
Add table
Reference in a new issue