aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBert Münnich <ber.t@posteo.de>2018-02-18 13:13:11 +0100
committerBert Münnich <ber.t@posteo.de>2018-02-18 14:12:41 +0100
commit48e0b70ad3dd550bf29810ec9b4f6ebdab3d7605 (patch)
tree5e1c7e67fa54b24cd859ccea8758d29afe9d706e
parent6d1e00627b7392f2ac32cdcddc7345a57a48cd6f (diff)
Ignore outdated inotify events
-rw-r--r--autoreload_inotify.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/autoreload_inotify.c b/autoreload_inotify.c
index de9cdf8..7c5b09a 100644
--- a/autoreload_inotify.c
+++ b/autoreload_inotify.c
@@ -85,7 +85,7 @@ bool arl_handle(arl_t *arl)
{
bool reload = false;
char *ptr;
- const struct inotify_event *event;
+ const struct inotify_event *e;
for (;;) {
ssize_t len = read(arl->fd, buf.d, sizeof(buf.d));
@@ -95,14 +95,14 @@ bool arl_handle(arl_t *arl)
continue;
break;
}
- for (ptr = buf.d; ptr < buf.d + len; ptr += sizeof(*event) + event->len) {
- event = (const struct inotify_event*) ptr;
- if (event->mask & IN_CLOSE_WRITE) {
+ for (ptr = buf.d; ptr < buf.d + len; ptr += sizeof(*e) + e->len) {
+ e = (const struct inotify_event*) ptr;
+ if (e->wd == arl->wd_file && (e->mask & IN_CLOSE_WRITE)) {
reload = true;
- } else if (event->mask & IN_DELETE_SELF) {
+ } else if (e->wd == arl->wd_file && (e->mask & IN_DELETE_SELF)) {
rm_watch(arl->fd, &arl->wd_file);
- } else if (event->mask & (IN_CREATE | IN_MOVED_TO)) {
- if (STREQ(event->name, arl->filename))
+ } else if (e->wd == arl->wd_dir && (e->mask & (IN_CREATE | IN_MOVED_TO))) {
+ if (STREQ(e->name, arl->filename))
reload = true;
}
}