Register inotify watch only if setup succeeds
authorMarcel Holtmann <marcel@holtmann.org>
Thu, 23 Apr 2009 08:04:38 +0000 (09:04 +0100)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 23 Apr 2009 08:04:38 +0000 (09:04 +0100)
plugins/loopback.c

index 04bd7a1..deaaac2 100644 (file)
@@ -101,9 +101,6 @@ static int create_watch(void)
                return -EIO;
        }
 
-       g_io_add_watch(inotify_channel, G_IO_IN | G_IO_ERR | G_IO_HUP,
-                                                       inotify_event, NULL);
-
        hostname_descriptor = inotify_add_watch(fd, "/etc/hostname",
                                IN_MODIFY | IN_DELETE_SELF | IN_MOVE_SELF);
        if (hostname_descriptor < 0) {
@@ -114,6 +111,9 @@ static int create_watch(void)
                return -EIO;
        }
 
+       g_io_add_watch(inotify_channel, G_IO_IN | G_IO_ERR | G_IO_HUP,
+                                                       inotify_event, NULL);
+
        return 0;
 }