evdev: Close the device gracefully in case of a read() error

Even with udev, the read fails before udev has a chance to signal the
change. Hence (and to handle errors gracefully anyway), let's remove the
device from the device manager in case of a read() error.
This commit is contained in:
Damien Lespiau 2010-11-09 13:02:53 -05:00
parent afd279dd76
commit 7cd6ba2828

View File

@ -157,7 +157,25 @@ clutter_event_dispatch (GSource *g_source,
{
if (errno != EAGAIN)
{
g_warning ("Could not read device (%d)", errno);
ClutterDeviceManager *manager;
ClutterInputDevice *device;
const gchar *device_path;
device = CLUTTER_INPUT_DEVICE (source->device);
if (CLUTTER_HAS_DEBUG (EVENT))
{
device_path =
_clutter_input_device_evdev_get_device_path (source->device);
CLUTTER_NOTE (EVENT, "Could not read device (%s), removing.",
device_path);
}
/* remove the faulty device */
manager = clutter_device_manager_get_default ();
_clutter_device_manager_remove_device (manager, device);
}
goto out;
}