mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-20 02:38:32 +00:00
Allow inotify to be disabled at compile time on Linux.
This commit is contained in:
@@ -9,7 +9,9 @@ version 2.73
|
|||||||
|
|
||||||
Use inotify for checking on updates to /etc/resolv.conf and
|
Use inotify for checking on updates to /etc/resolv.conf and
|
||||||
friends under Linux. This fixes race conditions when the files are
|
friends under Linux. This fixes race conditions when the files are
|
||||||
updated rapidly and saves CPU by noy polling.
|
updated rapidly and saves CPU by noy polling. To build
|
||||||
|
a binary that runs on old Linux kernels without inotify,
|
||||||
|
use make COPTS=-DNO_INOTIFY
|
||||||
|
|
||||||
Fix breakage of --domain=<domain>,<subnet>,local - only reverse
|
Fix breakage of --domain=<domain>,<subnet>,local - only reverse
|
||||||
queries were intercepted. THis appears to have been broken
|
queries were intercepted. THis appears to have been broken
|
||||||
|
|||||||
13
src/config.h
13
src/config.h
@@ -115,6 +115,8 @@ HAVE_DNSSEC
|
|||||||
HAVE_LOOP
|
HAVE_LOOP
|
||||||
include functionality to probe for and remove DNS forwarding loops.
|
include functionality to probe for and remove DNS forwarding loops.
|
||||||
|
|
||||||
|
HAVE_INOTIFY
|
||||||
|
use the Linux inotify facility to efficiently re-read configuration files.
|
||||||
|
|
||||||
NO_IPV6
|
NO_IPV6
|
||||||
NO_TFTP
|
NO_TFTP
|
||||||
@@ -123,6 +125,7 @@ NO_DHCP6
|
|||||||
NO_SCRIPT
|
NO_SCRIPT
|
||||||
NO_LARGEFILE
|
NO_LARGEFILE
|
||||||
NO_AUTH
|
NO_AUTH
|
||||||
|
NO_INOTIFY
|
||||||
these are avilable to explictly disable compile time options which would
|
these are avilable to explictly disable compile time options which would
|
||||||
otherwise be enabled automatically (HAVE_IPV6, >2Gb file sizes) or
|
otherwise be enabled automatically (HAVE_IPV6, >2Gb file sizes) or
|
||||||
which are enabled by default in the distributed source tree. Building dnsmasq
|
which are enabled by default in the distributed source tree. Building dnsmasq
|
||||||
@@ -355,6 +358,10 @@ HAVE_SOCKADDR_SA_LEN
|
|||||||
#undef HAVE_LOOP
|
#undef HAVE_LOOP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined (HAVE_LINUX_NETWORK) && !defined(NO_INOTIFY)
|
||||||
|
#define HAVE_INOTIFY
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Define a string indicating which options are in use.
|
/* Define a string indicating which options are in use.
|
||||||
DNSMASQP_COMPILE_OPTS is only defined in dnsmasq.c */
|
DNSMASQP_COMPILE_OPTS is only defined in dnsmasq.c */
|
||||||
|
|
||||||
@@ -428,7 +435,11 @@ static char *compile_opts =
|
|||||||
#ifndef HAVE_LOOP
|
#ifndef HAVE_LOOP
|
||||||
"no-"
|
"no-"
|
||||||
#endif
|
#endif
|
||||||
"loop-detect";
|
"loop-detect "
|
||||||
|
#ifndef HAVE_INOTIFY
|
||||||
|
"no-"
|
||||||
|
#endif
|
||||||
|
"inotify";
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -142,7 +142,9 @@ int main (int argc, char **argv)
|
|||||||
set_option_bool(OPT_NOWILD);
|
set_option_bool(OPT_NOWILD);
|
||||||
reset_option_bool(OPT_CLEVERBIND);
|
reset_option_bool(OPT_CLEVERBIND);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef HAVE_INOTIFY
|
||||||
if (daemon->inotify_hosts)
|
if (daemon->inotify_hosts)
|
||||||
die(_("dhcp-hostsdir not supported on this platform"), NULL, EC_BADCONF);
|
die(_("dhcp-hostsdir not supported on this platform"), NULL, EC_BADCONF);
|
||||||
#endif
|
#endif
|
||||||
@@ -321,7 +323,7 @@ int main (int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LINUX_NETWORK
|
#ifdef HAVE_INOTIFY
|
||||||
if ((!option_bool(OPT_NO_POLL) && daemon->port != 0) ||
|
if ((!option_bool(OPT_NO_POLL) && daemon->port != 0) ||
|
||||||
daemon->dhcp || daemon->doing_dhcp6)
|
daemon->dhcp || daemon->doing_dhcp6)
|
||||||
inotify_dnsmasq_init();
|
inotify_dnsmasq_init();
|
||||||
@@ -802,7 +804,7 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
pid = getpid();
|
pid = getpid();
|
||||||
|
|
||||||
#ifdef HAVE_LINUX_NETWORK
|
#ifdef HAVE_INOTIFY
|
||||||
/* Using inotify, have to select a resolv file at startup */
|
/* Using inotify, have to select a resolv file at startup */
|
||||||
poll_resolv(1, 0, now);
|
poll_resolv(1, 0, now);
|
||||||
#endif
|
#endif
|
||||||
@@ -873,14 +875,17 @@ int main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_LINUX_NETWORK)
|
#ifdef HAVE_INOTIFY
|
||||||
FD_SET(daemon->netlinkfd, &rset);
|
|
||||||
bump_maxfd(daemon->netlinkfd, &maxfd);
|
|
||||||
if (daemon->inotifyfd != -1)
|
if (daemon->inotifyfd != -1)
|
||||||
{
|
{
|
||||||
FD_SET(daemon->inotifyfd, &rset);
|
FD_SET(daemon->inotifyfd, &rset);
|
||||||
bump_maxfd(daemon->inotifyfd, &maxfd);
|
bump_maxfd(daemon->inotifyfd, &maxfd);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_LINUX_NETWORK)
|
||||||
|
FD_SET(daemon->netlinkfd, &rset);
|
||||||
|
bump_maxfd(daemon->netlinkfd, &maxfd);
|
||||||
#elif defined(HAVE_BSD_NETWORK)
|
#elif defined(HAVE_BSD_NETWORK)
|
||||||
FD_SET(daemon->routefd, &rset);
|
FD_SET(daemon->routefd, &rset);
|
||||||
bump_maxfd(daemon->routefd, &maxfd);
|
bump_maxfd(daemon->routefd, &maxfd);
|
||||||
@@ -948,7 +953,7 @@ int main (int argc, char **argv)
|
|||||||
route_sock();
|
route_sock();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_LINUX_NETWORK
|
#ifdef HAVE_INOTIFY
|
||||||
if (daemon->inotifyfd != -1 && FD_ISSET(daemon->inotifyfd, &rset) && inotify_check(now))
|
if (daemon->inotifyfd != -1 && FD_ISSET(daemon->inotifyfd, &rset) && inotify_check(now))
|
||||||
{
|
{
|
||||||
if (daemon->port != 0 && !option_bool(OPT_NO_POLL))
|
if (daemon->port != 0 && !option_bool(OPT_NO_POLL))
|
||||||
@@ -1394,7 +1399,7 @@ void clear_cache_and_reload(time_t now)
|
|||||||
if (option_bool(OPT_ETHERS))
|
if (option_bool(OPT_ETHERS))
|
||||||
dhcp_read_ethers();
|
dhcp_read_ethers();
|
||||||
reread_dhcp();
|
reread_dhcp();
|
||||||
#ifdef HAVE_LINUX_NETWORK
|
#ifdef HAVE_INOTIFY
|
||||||
set_dhcp_inotify();
|
set_dhcp_inotify();
|
||||||
#endif
|
#endif
|
||||||
dhcp_update_configs(daemon->dhcp_conf);
|
dhcp_update_configs(daemon->dhcp_conf);
|
||||||
|
|||||||
@@ -544,7 +544,7 @@ struct resolvc {
|
|||||||
int is_default, logged;
|
int is_default, logged;
|
||||||
time_t mtime;
|
time_t mtime;
|
||||||
char *name;
|
char *name;
|
||||||
#ifdef HAVE_LINUX_NETWORK
|
#ifdef HAVE_INOTIFY
|
||||||
int wd; /* inotify watch descriptor */
|
int wd; /* inotify watch descriptor */
|
||||||
char *file; /* pointer to file part if path */
|
char *file; /* pointer to file part if path */
|
||||||
#endif
|
#endif
|
||||||
@@ -558,7 +558,7 @@ struct hostsfile {
|
|||||||
struct hostsfile *next;
|
struct hostsfile *next;
|
||||||
int flags;
|
int flags;
|
||||||
char *fname;
|
char *fname;
|
||||||
#ifdef HAVE_LINUX_NETWORK
|
#ifdef HAVE_INOTIFY
|
||||||
int wd; /* inotify watch descriptor */
|
int wd; /* inotify watch descriptor */
|
||||||
#endif
|
#endif
|
||||||
unsigned int index; /* matches to cache entries for logging */
|
unsigned int index; /* matches to cache entries for logging */
|
||||||
@@ -1013,8 +1013,11 @@ extern struct daemon {
|
|||||||
|
|
||||||
/* DHCP state */
|
/* DHCP state */
|
||||||
int dhcpfd, helperfd, pxefd;
|
int dhcpfd, helperfd, pxefd;
|
||||||
|
#ifdef HAVE_INOTIFY
|
||||||
|
int inotifyfd;
|
||||||
|
#endif
|
||||||
#if defined(HAVE_LINUX_NETWORK)
|
#if defined(HAVE_LINUX_NETWORK)
|
||||||
int netlinkfd, inotifyfd;
|
int netlinkfd;
|
||||||
#elif defined(HAVE_BSD_NETWORK)
|
#elif defined(HAVE_BSD_NETWORK)
|
||||||
int dhcp_raw_fd, dhcp_icmp_fd, routefd;
|
int dhcp_raw_fd, dhcp_icmp_fd, routefd;
|
||||||
#endif
|
#endif
|
||||||
@@ -1488,7 +1491,7 @@ int detect_loop(char *query, int type);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* inotify.c */
|
/* inotify.c */
|
||||||
#ifdef HAVE_LINUX_NETWORK
|
#ifdef HAVE_INOTIFY
|
||||||
void inotify_dnsmasq_init();
|
void inotify_dnsmasq_init();
|
||||||
int inotify_check(time_t now);
|
int inotify_check(time_t now);
|
||||||
# ifdef HAVE_DHCP
|
# ifdef HAVE_DHCP
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "dnsmasq.h"
|
#include "dnsmasq.h"
|
||||||
#ifdef HAVE_LINUX_NETWORK
|
#ifdef HAVE_INOTIFY
|
||||||
|
|
||||||
#include <sys/inotify.h>
|
#include <sys/inotify.h>
|
||||||
|
|
||||||
@@ -216,5 +216,5 @@ static void check_for_dhcp_inotify(struct inotify_event *in, time_t now)
|
|||||||
|
|
||||||
#endif /* DHCP */
|
#endif /* DHCP */
|
||||||
|
|
||||||
#endif /* LINUX_NETWORK */
|
#endif /* INOTIFY */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user