]> git.pld-linux.org Git - packages/cronie.git/blame - cronie-1.4.8-inotify-fix.patch
- versioned vixie-cron trigger
[packages/cronie.git] / cronie-1.4.8-inotify-fix.patch
CommitLineData
5c77a7a7
AM
1diff --git a/src/cron.c b/src/cron.c
2index 7dc2958..7917589 100644
3--- a/src/cron.c
4+++ b/src/cron.c
5@@ -64,11 +64,19 @@ static int DisableInotify;
6 int wd[NUM_WATCHES];
7 const char *watchpaths[NUM_WATCHES] = {SPOOL_DIR, SYS_CROND_DIR, SYSCRONTAB};
8
9+static void reset_watches(void) {
10+ int i;
11+
12+ for (i = 0; i < sizeof (wd) / sizeof (wd[0]); ++i) {
13+ wd[i] = -2;
14+ }
15+}
16+
17 void set_cron_unwatched(int fd) {
18 int i;
19
20 for (i = 0; i < sizeof (wd) / sizeof (wd[0]); ++i) {
21- if (wd[i] < 0) {
22+ if (wd[i] > 0) {
23 inotify_rm_watch(fd, wd[i]);
24 wd[i] = -1;
25 }
26@@ -87,22 +95,21 @@ void set_cron_watched(int fd) {
27 for (i = 0; i < sizeof (wd) / sizeof (wd[0]); ++i) {
28 int w;
29
30- if (open(watchpaths[i], O_RDONLY | O_NONBLOCK, 0) != -1) {
31- w = inotify_add_watch(fd, watchpaths[i],
32- IN_CREATE | IN_CLOSE_WRITE | IN_ATTRIB | IN_MODIFY | IN_MOVED_TO |
33- IN_MOVED_FROM | IN_MOVE_SELF | IN_DELETE | IN_DELETE_SELF);
34- if (w < 0) {
35- if (wd[i] != -1) {
36- log_it("CRON", pid, "This directory or file can't be watched",
37- watchpaths[i], errno);
38- log_it("CRON", pid, "INFO", "running without inotify support", 0);
39- }
40- inotify_enabled = 0;
41- set_cron_unwatched(fd);
42- return;
43+ w = inotify_add_watch(fd, watchpaths[i],
44+ IN_CREATE | IN_CLOSE_WRITE | IN_ATTRIB | IN_MODIFY | IN_MOVED_TO |
45+ IN_MOVED_FROM | IN_MOVE_SELF | IN_DELETE | IN_DELETE_SELF);
46+ if (w < 0 && errno != ENOENT) {
47+ if (wd[i] != -1) {
48+ log_it("CRON", pid, "This directory or file can't be watched",
49+ watchpaths[i], errno);
50+ log_it("CRON", pid, "INFO", "running without inotify support",
51+ 0);
52 }
53- wd[i] = w;
54+ inotify_enabled = 0;
55+ set_cron_unwatched(fd);
56+ return;
57 }
58+ wd[i] = w;
59 }
60
61 if (!inotify_enabled) {
62@@ -120,6 +127,7 @@ static void handle_signals(cron_db * database) {
63 /* watches must be reinstated on reload */
64 if (inotify_enabled && (EnableClustering != 1)) {
65 set_cron_unwatched(database->ifd);
66+ reset_watches();
67 inotify_enabled = 0;
68 }
69 #endif
70@@ -158,9 +166,6 @@ int main(int argc, char *argv[]) {
71 char *cs;
72 pid_t pid = getpid();
73 long oldGMToff;
74-#if defined WITH_INOTIFY
75- int i;
76-#endif
77
78 ProgramName = argv[0];
79 MailCmd[0] = '\0';
80@@ -261,13 +266,7 @@ int main(int argc, char *argv[]) {
81 "", 0);
82 }
83 else {
84- for (i = 0; i < sizeof (wd) / sizeof (wd[0]); ++i) {
85- /* initialize to negative number other than -1
86- * so an eventual error is reported for the first time
87- */
88- wd[i] = -2;
89- }
90-
91+ reset_watches();
92 database.ifd = fd = inotify_init();
93 fcntl(fd, F_SETFD, FD_CLOEXEC);
94 if (fd < 0)
This page took 0.077284 seconds and 4 git commands to generate.