summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2011-07-18 21:17:10 +0200
committerPeter Hutterer <peter.hutterer@who-t.net>2011-07-27 09:29:39 +1000
commit882e3c2680c339ad7aa0d664e0b0f02b8a05b11d (patch)
tree74ae25933d57d354ad4930fe67f59b60121fc9e0
parent82f5521a6d91ebcd2a4400f6c221ad625edc99a1 (diff)
config: process udev "changed" and "add" events in the same code paths
udev gives no guarantee that before each "changed" event for a device there's an "add" event, or that before each "remove" is an "add", or that before each "add" there was no "add" already and so on. Users can trigger these events at any time with "udevadm trigger", and netlink is a lossy transport, hence the events can come in unexpected ordering. With other words: regardless which event is generated, the X server must not choke on it and make the best of it, hence make sure that if we get an "add" event for an existing device we don't add the device a second time. Signed-off-by: Lennart Poettering <lennart@poettering.net> Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net> Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
-rw-r--r--config/udev.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/config/udev.c b/config/udev.c
index 9ac34ee50..5ac52a1d7 100644
--- a/config/udev.c
+++ b/config/udev.c
@@ -251,14 +251,12 @@ wakeup_handler(pointer data, int err, pointer read_mask)
return;
action = udev_device_get_action(udev_device);
if (action) {
- if (!strcmp(action, "add"))
- device_added(udev_device);
- else if (!strcmp(action, "remove"))
- device_removed(udev_device);
- else if (!strcmp(action, "change")) {
+ if (!strcmp(action, "add") || !strcmp(action, "change")) {
device_removed(udev_device);
device_added(udev_device);
}
+ else if (!strcmp(action, "remove"))
+ device_removed(udev_device);
}
udev_device_unref(udev_device);
}