Use inotify for checking on updates to /etc/resolv.conf and
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
queries were intercepted. THis appears to have been broken
HAVE_LOOP
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_TFTP
NO_SCRIPT
NO_LARGEFILE
NO_AUTH
+NO_INOTIFY
these are avilable to explictly disable compile time options which would
otherwise be enabled automatically (HAVE_IPV6, >2Gb file sizes) or
which are enabled by default in the distributed source tree. Building dnsmasq
#undef HAVE_LOOP
#endif
+#if defined (HAVE_LINUX_NETWORK) && !defined(NO_INOTIFY)
+#define HAVE_INOTIFY
+#endif
+
/* Define a string indicating which options are in use.
DNSMASQP_COMPILE_OPTS is only defined in dnsmasq.c */
#ifndef HAVE_LOOP
"no-"
#endif
-"loop-detect";
+"loop-detect "
+#ifndef HAVE_INOTIFY
+"no-"
+#endif
+"inotify";
#endif
set_option_bool(OPT_NOWILD);
reset_option_bool(OPT_CLEVERBIND);
}
+#endif
+#ifndef HAVE_INOTIFY
if (daemon->inotify_hosts)
die(_("dhcp-hostsdir not supported on this platform"), NULL, EC_BADCONF);
#endif
#endif
}
-#ifdef HAVE_LINUX_NETWORK
+#ifdef HAVE_INOTIFY
if ((!option_bool(OPT_NO_POLL) && daemon->port != 0) ||
daemon->dhcp || daemon->doing_dhcp6)
inotify_dnsmasq_init();
pid = getpid();
-#ifdef HAVE_LINUX_NETWORK
+#ifdef HAVE_INOTIFY
/* Using inotify, have to select a resolv file at startup */
poll_resolv(1, 0, now);
#endif
bump_maxfd(daemon->icmp6fd, &maxfd);
}
#endif
-
-#if defined(HAVE_LINUX_NETWORK)
- FD_SET(daemon->netlinkfd, &rset);
- bump_maxfd(daemon->netlinkfd, &maxfd);
+
+#ifdef HAVE_INOTIFY
if (daemon->inotifyfd != -1)
{
FD_SET(daemon->inotifyfd, &rset);
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)
FD_SET(daemon->routefd, &rset);
bump_maxfd(daemon->routefd, &maxfd);
route_sock();
#endif
-#ifdef HAVE_LINUX_NETWORK
+#ifdef HAVE_INOTIFY
if (daemon->inotifyfd != -1 && FD_ISSET(daemon->inotifyfd, &rset) && inotify_check(now))
{
if (daemon->port != 0 && !option_bool(OPT_NO_POLL))
if (option_bool(OPT_ETHERS))
dhcp_read_ethers();
reread_dhcp();
-#ifdef HAVE_LINUX_NETWORK
+#ifdef HAVE_INOTIFY
set_dhcp_inotify();
#endif
dhcp_update_configs(daemon->dhcp_conf);
int is_default, logged;
time_t mtime;
char *name;
-#ifdef HAVE_LINUX_NETWORK
+#ifdef HAVE_INOTIFY
int wd; /* inotify watch descriptor */
char *file; /* pointer to file part if path */
#endif
struct hostsfile *next;
int flags;
char *fname;
-#ifdef HAVE_LINUX_NETWORK
+#ifdef HAVE_INOTIFY
int wd; /* inotify watch descriptor */
#endif
unsigned int index; /* matches to cache entries for logging */
/* DHCP state */
int dhcpfd, helperfd, pxefd;
+#ifdef HAVE_INOTIFY
+ int inotifyfd;
+#endif
#if defined(HAVE_LINUX_NETWORK)
- int netlinkfd, inotifyfd;
+ int netlinkfd;
#elif defined(HAVE_BSD_NETWORK)
int dhcp_raw_fd, dhcp_icmp_fd, routefd;
#endif
#endif
/* inotify.c */
-#ifdef HAVE_LINUX_NETWORK
+#ifdef HAVE_INOTIFY
void inotify_dnsmasq_init();
int inotify_check(time_t now);
# ifdef HAVE_DHCP
*/
#include "dnsmasq.h"
-#ifdef HAVE_LINUX_NETWORK
+#ifdef HAVE_INOTIFY
#include <sys/inotify.h>
#endif /* DHCP */
-#endif /* LINUX_NETWORK */
+#endif /* INOTIFY */