summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org>2014-08-31 14:27:45 (GMT)
committer Sergey Poznyakoff <gray@gnu.org>2014-08-31 14:27:45 (GMT)
commit92eeafbe6b3c68a51b11dbe773d909982acfb1b9 (patch) (side-by-side diff)
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.
Diffstat (more/less context) (ignore whitespace changes)
-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)
for (ep = eventconf.pathlist->head; ep; ep = ep->next) {
struct pathent *pe = ep->data;
struct dirwatcher *dwp;
- struct handler *hp, *prev = NULL;
+ struct handler *hp;
+ int isnew;
- dwp = dirwatcher_install(pe->path, NULL);
+ dwp = dirwatcher_install(pe->path, &isnew);
if (!dwp)
abort();
+ if (!isnew && dwp->depth != pe->depth)
+ grecs_error(loc, 0,
+ _("%s: recursion depth does not match previous definition"),
+ pe->path);
dwp->depth = pe->depth;
- for (hp = dwp->handler_list; hp; prev = hp, hp = hp->next) {
- if (strcmp(dwp->dirname, pe->path) == 0) {
- grecs_error(loc, 0,
- _("ignoring duplicate definition"));
- return;
- }
- }
-
+
hp = emalloc(sizeof(*hp));
hp->next = NULL;
hp->ev_mask = eventconf.eventmask;
@@ -224,10 +222,11 @@ eventconf_flush(grecs_locus_t *loc)
hp->gidv = eventconf.gidv;
hp->env = eventconf.env;
- if (prev)
- prev->next = hp;
+ if (dwp->handler_tail)
+ dwp->handler_tail->next = hp;
else
dwp->handler_list = hp;
+ dwp->handler_tail = hp;
}
grecs_list_free(eventconf.pathlist);
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 {
struct dirwatcher *parent; /* Points to the parent watcher.
NULL for top-level watchers */
char *dirname; /* Pathname being watched */
- struct handler *handler_list; /* Handlers */
- int depth;
- char *split_p;
+ struct handler *handler_list; /* List of handlers */
+ struct handler *handler_tail; /* Tail of the handler list */
+ int depth; /* Recursion depth */
+ char *split_p; /* Points to the deleted directory
+ separator in dirname (see
+ split_pathname,
+ unsplit_pathname */
#if USE_IFACE == IFACE_KQUEUE
mode_t file_mode;
time_t file_ctime;

Return to:

Send suggestions and report system problems to the System administrator.