From b8e96d67a2c842dc750b5193cb732a077a3149ed Mon Sep 17 00:00:00 2001 From: Scott James Remnant Date: Mon, 23 Feb 2009 17:59:01 +0000 Subject: [PATCH] lookup the old watch handle; reload only if has a path --- udev/udevd.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/udev/udevd.c b/udev/udevd.c index c764b33b..5598628a 100644 --- a/udev/udevd.c +++ b/udev/udevd.c @@ -216,7 +216,15 @@ static void event_fork(struct udev_event *event) alarm(UDEV_EVENT_TIMEOUT); /* clear any existing udev watch on the node */ - udev_watch_end(event->udev, event->dev); + if (inotify_fd != -1) { + struct udev_device *dev_old; + + dev_old = udev_device_new_from_syspath(event->udev, udev_device_get_syspath(event->dev)); + if (dev_old != NULL) { + udev_watch_end(event->udev, dev_old); + udev_device_unref(dev_old); + } + } /* apply rules, create node, symlinks */ err = udev_event_execute_rules(event, rules); @@ -541,7 +549,12 @@ static int handle_inotify(struct udev *udev) for (pos = 0, ev = (struct inotify_event *)(buf + pos); pos < nbytes; pos += sizeof(struct inotify_event) + ev->len) { struct udev_device *dev; - dbg(udev, "inotify event: %x for %d (%s)\n", ev->mask, ev->wd, ev->len ? ev->name : "*"); + if (ev->len) { + dbg(udev, "inotify event: %x for %s\n", ev->mask, ev->name); + reload_config = 1; + continue; + } + dev = udev_watch_lookup(udev, ev->wd); if (dev != NULL) { dbg(udev, "inotify event: %x for %s\n", ev->mask, udev_device_get_devnode(dev)); @@ -561,9 +574,8 @@ static int handle_inotify(struct udev *udev) udev_watch_end(udev, dev); udev_device_unref(dev); - } else { - reload_config = 1; } + } free (buf); -- 2.39.5