aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org>2014-08-31 17:27:45 +0300
committerSergey Poznyakoff <gray@gnu.org>2014-08-31 17:27:45 +0300
commit92eeafbe6b3c68a51b11dbe773d909982acfb1b9 (patch)
treecc25173ed06fa2a783ac090fa77b77f062c265ac
parent0e2589f4c5a4cca6ee7713664544d5f5fb0e1936 (diff)
downloaddirevent-92eeafbe6b3c68a51b11dbe773d909982acfb1b9.tar.gz
direvent-92eeafbe6b3c68a51b11dbe773d909982acfb1b9.tar.bz2
Accept multpile watchers for the same path
* src/direvent.h (dirwatcher)<handler_tail>: New member. * src/config.c (eventconf_flush): Use handler_tail to update the handler list. Remove erroneous check.
-rw-r--r--src/config.c23
-rw-r--r--src/direvent.h10
2 files changed, 18 insertions, 15 deletions
diff --git a/src/config.c b/src/config.c
index 82262a8..ef95211 100644
--- a/src/config.c
+++ b/src/config.c
@@ -198,20 +198,18 @@ eventconf_flush(grecs_locus_t *loc)
198 for (ep = eventconf.pathlist->head; ep; ep = ep->next) { 198 for (ep = eventconf.pathlist->head; ep; ep = ep->next) {
199 struct pathent *pe = ep->data; 199 struct pathent *pe = ep->data;
200 struct dirwatcher *dwp; 200 struct dirwatcher *dwp;
201 struct handler *hp, *prev = NULL; 201 struct handler *hp;
202 int isnew;
202 203
203 dwp = dirwatcher_install(pe->path, NULL); 204 dwp = dirwatcher_install(pe->path, &isnew);
204 if (!dwp) 205 if (!dwp)
205 abort(); 206 abort();
207 if (!isnew && dwp->depth != pe->depth)
208 grecs_error(loc, 0,
209 _("%s: recursion depth does not match previous definition"),
210 pe->path);
206 dwp->depth = pe->depth; 211 dwp->depth = pe->depth;
207 for (hp = dwp->handler_list; hp; prev = hp, hp = hp->next) { 212
208 if (strcmp(dwp->dirname, pe->path) == 0) {
209 grecs_error(loc, 0,
210 _("ignoring duplicate definition"));
211 return;
212 }
213 }
214
215 hp = emalloc(sizeof(*hp)); 213 hp = emalloc(sizeof(*hp));
216 hp->next = NULL; 214 hp->next = NULL;
217 hp->ev_mask = eventconf.eventmask; 215 hp->ev_mask = eventconf.eventmask;
@@ -224,10 +222,11 @@ eventconf_flush(grecs_locus_t *loc)
224 hp->gidv = eventconf.gidv; 222 hp->gidv = eventconf.gidv;
225 hp->env = eventconf.env; 223 hp->env = eventconf.env;
226 224
227 if (prev) 225 if (dwp->handler_tail)
228 prev->next = hp; 226 dwp->handler_tail->next = hp;
229 else 227 else
230 dwp->handler_list = hp; 228 dwp->handler_list = hp;
229 dwp->handler_tail = hp;
231 } 230 }
232 grecs_list_free(eventconf.pathlist); 231 grecs_list_free(eventconf.pathlist);
233 eventconf_init(); 232 eventconf_init();
diff --git a/src/direvent.h b/src/direvent.h
index 069d3d8..07dfd0b 100644
--- a/src/direvent.h
+++ b/src/direvent.h
@@ -89,9 +89,13 @@ struct dirwatcher {
89 struct dirwatcher *parent; /* Points to the parent watcher. 89 struct dirwatcher *parent; /* Points to the parent watcher.
90 NULL for top-level watchers */ 90 NULL for top-level watchers */
91 char *dirname; /* Pathname being watched */ 91 char *dirname; /* Pathname being watched */
92 struct handler *handler_list; /* Handlers */ 92 struct handler *handler_list; /* List of handlers */
93 int depth; 93 struct handler *handler_tail; /* Tail of the handler list */
94 char *split_p; 94 int depth; /* Recursion depth */
95 char *split_p; /* Points to the deleted directory
96 separator in dirname (see
97 split_pathname,
98 unsplit_pathname */
95#if USE_IFACE == IFACE_KQUEUE 99#if USE_IFACE == IFACE_KQUEUE
96 mode_t file_mode; 100 mode_t file_mode;
97 time_t file_ctime; 101 time_t file_ctime;

Return to:

Send suggestions and report system problems to the System administrator.