notify_inotify: Slightly simplify watch_destructor
authorVolker Lendecke <vl@samba.org>
Mon, 27 Oct 2014 13:20:15 +0000 (13:20 +0000)
committerJeremy Allison <jra@samba.org>
Tue, 9 Dec 2014 03:12:09 +0000 (04:12 +0100)
Another case of an early return

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/notify_inotify.c

index b141b9211681e00ba7208bc0c7bad54b4f6b6e04..3e4e2e6a566544b89f78cf2f23530b0deb147220 100644 (file)
@@ -324,17 +324,19 @@ static int watch_destructor(struct inotify_watch_context *w)
        int wd = w->wd;
        DLIST_REMOVE(w->in->watches, w);
 
-       /* only rm the watch if its the last one with this wd */
        for (w=in->watches;w;w=w->next) {
-               if (w->wd == wd) break;
-       }
-       if (w == NULL) {
-               DEBUG(10, ("Deleting inotify watch %d\n", wd));
-               if (inotify_rm_watch(in->fd, wd) == -1) {
-                       DEBUG(1, ("inotify_rm_watch returned %s\n",
-                                 strerror(errno)));
+               if (w->wd == wd) {
+                       /*
+                        * Another inotify_watch_context listens on this path,
+                        * leave the kernel level watch in place
+                        */
+                       return 0;
                }
+       }
 
+       DEBUG(10, ("Deleting inotify watch %d\n", wd));
+       if (inotify_rm_watch(in->fd, wd) == -1) {
+               DEBUG(1, ("inotify_rm_watch returned %s\n", strerror(errno)));
        }
        return 0;
 }