1 From 0491805d2ff6e7727f0272c94fd97d9897d1e22c Mon Sep 17 00:00:00 2001
2 From: Simon Kelley <simon@thekelleys.org.uk>
3 Date: Mon, 26 Jan 2015 11:23:43 +0000
4 Subject: [PATCH 037/113] Allow inotify to be disabled at compile time on
9 src/config.h | 13 ++++++++++++-
10 src/dnsmasq.c | 21 +++++++++++++--------
11 src/dnsmasq.h | 11 +++++++----
12 src/inotify.c | 4 ++--
13 5 files changed, 37 insertions(+), 16 deletions(-)
15 diff --git a/CHANGELOG b/CHANGELOG
16 index a4cb901e83ae..c05dec63c587 100644
19 @@ -9,7 +9,9 @@ version 2.73
21 Use inotify for checking on updates to /etc/resolv.conf and
22 friends under Linux. This fixes race conditions when the files are
23 - updated rapidly and saves CPU by noy polling.
24 + updated rapidly and saves CPU by noy polling. To build
25 + a binary that runs on old Linux kernels without inotify,
26 + use make COPTS=-DNO_INOTIFY
28 Fix breakage of --domain=<domain>,<subnet>,local - only reverse
29 queries were intercepted. THis appears to have been broken
30 diff --git a/src/config.h b/src/config.h
31 index cdca231b4079..5e5009271eba 100644
34 @@ -115,6 +115,8 @@ HAVE_DNSSEC
36 include functionality to probe for and remove DNS forwarding loops.
39 + use the Linux inotify facility to efficiently re-read configuration files.
43 @@ -123,6 +125,7 @@ NO_DHCP6
48 these are avilable to explictly disable compile time options which would
49 otherwise be enabled automatically (HAVE_IPV6, >2Gb file sizes) or
50 which are enabled by default in the distributed source tree. Building dnsmasq
51 @@ -355,6 +358,10 @@ HAVE_SOCKADDR_SA_LEN
55 +#if defined (HAVE_LINUX_NETWORK) && !defined(NO_INOTIFY)
59 /* Define a string indicating which options are in use.
60 DNSMASQP_COMPILE_OPTS is only defined in dnsmasq.c */
62 @@ -428,7 +435,11 @@ static char *compile_opts =
75 diff --git a/src/dnsmasq.c b/src/dnsmasq.c
76 index 04cc98278f62..bc4f47170705 100644
79 @@ -142,7 +142,9 @@ int main (int argc, char **argv)
80 set_option_bool(OPT_NOWILD);
81 reset_option_bool(OPT_CLEVERBIND);
86 if (daemon->inotify_hosts)
87 die(_("dhcp-hostsdir not supported on this platform"), NULL, EC_BADCONF);
89 @@ -321,7 +323,7 @@ int main (int argc, char **argv)
93 -#ifdef HAVE_LINUX_NETWORK
95 if ((!option_bool(OPT_NO_POLL) && daemon->port != 0) ||
96 daemon->dhcp || daemon->doing_dhcp6)
97 inotify_dnsmasq_init();
98 @@ -802,7 +804,7 @@ int main (int argc, char **argv)
102 -#ifdef HAVE_LINUX_NETWORK
104 /* Using inotify, have to select a resolv file at startup */
105 poll_resolv(1, 0, now);
107 @@ -872,15 +874,18 @@ int main (int argc, char **argv)
108 bump_maxfd(daemon->icmp6fd, &maxfd);
112 -#if defined(HAVE_LINUX_NETWORK)
113 - FD_SET(daemon->netlinkfd, &rset);
114 - bump_maxfd(daemon->netlinkfd, &maxfd);
117 if (daemon->inotifyfd != -1)
119 FD_SET(daemon->inotifyfd, &rset);
120 bump_maxfd(daemon->inotifyfd, &maxfd);
124 +#if defined(HAVE_LINUX_NETWORK)
125 + FD_SET(daemon->netlinkfd, &rset);
126 + bump_maxfd(daemon->netlinkfd, &maxfd);
127 #elif defined(HAVE_BSD_NETWORK)
128 FD_SET(daemon->routefd, &rset);
129 bump_maxfd(daemon->routefd, &maxfd);
130 @@ -948,7 +953,7 @@ int main (int argc, char **argv)
134 -#ifdef HAVE_LINUX_NETWORK
136 if (daemon->inotifyfd != -1 && FD_ISSET(daemon->inotifyfd, &rset) && inotify_check(now))
138 if (daemon->port != 0 && !option_bool(OPT_NO_POLL))
139 @@ -1394,7 +1399,7 @@ void clear_cache_and_reload(time_t now)
140 if (option_bool(OPT_ETHERS))
143 -#ifdef HAVE_LINUX_NETWORK
147 dhcp_update_configs(daemon->dhcp_conf);
148 diff --git a/src/dnsmasq.h b/src/dnsmasq.h
149 index d841fdc064ad..8091634f69db 100644
152 @@ -544,7 +544,7 @@ struct resolvc {
153 int is_default, logged;
156 -#ifdef HAVE_LINUX_NETWORK
158 int wd; /* inotify watch descriptor */
159 char *file; /* pointer to file part if path */
161 @@ -558,7 +558,7 @@ struct hostsfile {
162 struct hostsfile *next;
165 -#ifdef HAVE_LINUX_NETWORK
167 int wd; /* inotify watch descriptor */
169 unsigned int index; /* matches to cache entries for logging */
170 @@ -1013,8 +1013,11 @@ extern struct daemon {
173 int dhcpfd, helperfd, pxefd;
177 #if defined(HAVE_LINUX_NETWORK)
178 - int netlinkfd, inotifyfd;
180 #elif defined(HAVE_BSD_NETWORK)
181 int dhcp_raw_fd, dhcp_icmp_fd, routefd;
183 @@ -1488,7 +1491,7 @@ int detect_loop(char *query, int type);
187 -#ifdef HAVE_LINUX_NETWORK
189 void inotify_dnsmasq_init();
190 int inotify_check(time_t now);
192 diff --git a/src/inotify.c b/src/inotify.c
193 index 52a30d7f44db..818fe8eddda4 100644
200 -#ifdef HAVE_LINUX_NETWORK
203 #include <sys/inotify.h>
205 @@ -216,5 +216,5 @@ static void check_for_dhcp_inotify(struct inotify_event *in, time_t now)
209 -#endif /* LINUX_NETWORK */
210 +#endif /* INOTIFY */