From 92c32e0bace9ba11bea2cb77912695da3221f656 Mon Sep 17 00:00:00 2001 From: Dominik Derigs Date: Thu, 27 Oct 2022 12:36:38 +0100 Subject: [PATCH] Do not (try to) re-read deleted files inside a --hostsdir. Conflict:NA Reference:https://thekelleys.org.uk/gitweb/?p=dnsmasq.git;a=commit;h=id=92c32e0bace9ba11bea2cb77912695da3221f656 --- src/inotify.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/inotify.c b/src/inotify.c index 5776feb..438a622 100644 --- a/src/inotify.c +++ b/src/inotify.c @@ -253,12 +253,18 @@ int inotify_check(time_t now) strcpy(path, ah->fname); strcat(path, "/"); strcat(path, in->name); - - my_syslog(LOG_INFO, _("inotify, new or changed file %s"), path); + + /* Is this is a deletion event? */ + if (in->mask & IN_DELETE) + my_syslog(LOG_INFO, _("inotify: %s (removed)"), path); + else + my_syslog(LOG_INFO, _("inotify: %s (new or modified)"), path); if (ah->flags & AH_HOSTS) { - read_hostsfile(path, ah->index, 0, NULL, 0); + /* (Re-)load hostsfile only if this event isn't triggered by deletion */ + if (!(in->mask & IN_DELETE)) + read_hostsfile(path, ah->index, 0, NULL, 0); #ifdef HAVE_DHCP if (daemon->dhcp || daemon->doing_dhcp6) { -- 2.27.0