On Tue, Oct 15, 2013 at 02:29:56PM +0200, David Herrmann wrote:
> 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()).
> ---
>  src/evdev.c | 9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)

Looks good, committed.
Kristian

> diff --git a/src/evdev.c b/src/evdev.c
> index edea396..7397ea1 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;
>               }
>  
> -- 
> 1.8.4
> 
_______________________________________________
wayland-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/wayland-devel

Reply via email to