Don't create a useless inotify file desrcriptor when --port=0

If there are no dynamic configuration directories configured with
dhcp-hostsdir, dhcp-optsdir and hostsdir then we need to use inotify
only to track changes to resolv-files, but we don't need to do
that when DNS is disabled (port=0) or no resolv-files are configured.

It turns out that inotify slots can be a scarce resource, so not
using one when it's not needed is a Goood Thing.

Patch by HL, description above from SRK.
This commit is contained in:
Heikki Linnakangas
2024-02-07 14:44:49 +00:00
committed by Simon Kelley
parent 6d35601da4
commit 762a3f2430
2 changed files with 3 additions and 3 deletions

View File

@@ -421,8 +421,8 @@ int main (int argc, char **argv)
} }
#ifdef HAVE_INOTIFY #ifdef HAVE_INOTIFY
if ((daemon->port != 0 || daemon->dhcp || daemon->doing_dhcp6) if ((daemon->port != 0 && !option_bool(OPT_NO_RESOLV)) ||
&& (!option_bool(OPT_NO_RESOLV) || daemon->dynamic_dirs)) daemon->dynamic_dirs)
inotify_dnsmasq_init(); inotify_dnsmasq_init();
else else
daemon->inotifyfd = -1; daemon->inotifyfd = -1;

View File

@@ -94,7 +94,7 @@ void inotify_dnsmasq_init()
if (daemon->inotifyfd == -1) if (daemon->inotifyfd == -1)
die(_("failed to create inotify: %s"), NULL, EC_MISC); die(_("failed to create inotify: %s"), NULL, EC_MISC);
if (option_bool(OPT_NO_RESOLV)) if (daemon->port == 0 || option_bool(OPT_NO_RESOLV))
return; return;
for (res = daemon->resolv_files; res; res = res->next) for (res = daemon->resolv_files; res; res = res->next)