Revert "Cronie disables inotify support when the /etc/crontab file does not exist...
authorTomas Mraz <tmraz@fedoraproject.org>
Wed, 29 Jun 2011 09:06:24 +0000 (11:06 +0200)
committerTomas Mraz <tmraz@fedoraproject.org>
Wed, 29 Jun 2011 09:06:24 +0000 (11:06 +0200)
This reverts commit acdf4ae8456888ed78201906ef528f4c28f54582 as it introduces
fd leaks.

src/cron.c

index 7dc2958ad7db181819cefc7554f5d44af6a70fee..69261c15c857cde7c10bda93c399929f28191e7f 100644 (file)
@@ -87,22 +87,21 @@ void set_cron_watched(int fd) {
        for (i = 0; i < sizeof (wd) / sizeof (wd[0]); ++i) {
                int w;
 
-               if (open(watchpaths[i], O_RDONLY | O_NONBLOCK, 0) != -1) {
-                       w = inotify_add_watch(fd, watchpaths[i],
-                               IN_CREATE | IN_CLOSE_WRITE | IN_ATTRIB | IN_MODIFY | IN_MOVED_TO |
-                               IN_MOVED_FROM | IN_MOVE_SELF | IN_DELETE | IN_DELETE_SELF);
-                       if (w < 0) {
-                               if (wd[i] != -1) {
-                                       log_it("CRON", pid, "This directory or file can't be watched",
-                                               watchpaths[i], errno);
-                                       log_it("CRON", pid, "INFO", "running without inotify support", 0);
-                               }
-                               inotify_enabled = 0;
-                               set_cron_unwatched(fd);
-                               return;
+               w = inotify_add_watch(fd, watchpaths[i],
+                       IN_CREATE | IN_CLOSE_WRITE | IN_ATTRIB | IN_MODIFY | IN_MOVED_TO |
+                       IN_MOVED_FROM | IN_MOVE_SELF | IN_DELETE | IN_DELETE_SELF);
+               if (w < 0) {
+                       if (wd[i] != -1) {
+                               log_it("CRON", pid, "This directory or file can't be watched",
+                                       watchpaths[i], errno);
+                               log_it("CRON", pid, "INFO", "running without inotify support",
+                                       0);
                        }
-                       wd[i] = w;
+                       inotify_enabled = 0;
+                       set_cron_unwatched(fd);
+                       return;
                }
+               wd[i] = w;
        }
 
        if (!inotify_enabled) {