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 37/87] Allow inotify to be disabled at compile time on Linux.
8 src/config.h | 13 ++++++++++++-
9 src/dnsmasq.c | 21 +++++++++++++--------
10 src/dnsmasq.h | 11 +++++++----
11 src/inotify.c | 4 ++--
12 5 files changed, 37 insertions(+), 16 deletions(-)
14 diff --git a/CHANGELOG b/CHANGELOG
15 index a4cb901e83ae..c05dec63c587 100644
18 @@ -9,7 +9,9 @@ version 2.73
20 Use inotify for checking on updates to /etc/resolv.conf and
21 friends under Linux. This fixes race conditions when the files are
22 - updated rapidly and saves CPU by noy polling.
23 + updated rapidly and saves CPU by noy polling. To build
24 + a binary that runs on old Linux kernels without inotify,
25 + use make COPTS=-DNO_INOTIFY
27 Fix breakage of --domain=<domain>,<subnet>,local - only reverse
28 queries were intercepted. THis appears to have been broken
29 diff --git a/src/config.h b/src/config.h
30 index cdca231b4079..5e5009271eba 100644
33 @@ -115,6 +115,8 @@ HAVE_DNSSEC
35 include functionality to probe for and remove DNS forwarding loops.
38 + use the Linux inotify facility to efficiently re-read configuration files.
42 @@ -123,6 +125,7 @@ NO_DHCP6
47 these are avilable to explictly disable compile time options which would
48 otherwise be enabled automatically (HAVE_IPV6, >2Gb file sizes) or
49 which are enabled by default in the distributed source tree. Building dnsmasq
50 @@ -355,6 +358,10 @@ HAVE_SOCKADDR_SA_LEN
54 +#if defined (HAVE_LINUX_NETWORK) && !defined(NO_INOTIFY)
58 /* Define a string indicating which options are in use.
59 DNSMASQP_COMPILE_OPTS is only defined in dnsmasq.c */
61 @@ -428,7 +435,11 @@ static char *compile_opts =
74 diff --git a/src/dnsmasq.c b/src/dnsmasq.c
75 index 04cc98278f62..bc4f47170705 100644
78 @@ -142,7 +142,9 @@ int main (int argc, char **argv)
79 set_option_bool(OPT_NOWILD);
80 reset_option_bool(OPT_CLEVERBIND);
85 if (daemon->inotify_hosts)
86 die(_("dhcp-hostsdir not supported on this platform"), NULL, EC_BADCONF);
88 @@ -321,7 +323,7 @@ int main (int argc, char **argv)
92 -#ifdef HAVE_LINUX_NETWORK
94 if ((!option_bool(OPT_NO_POLL) && daemon->port != 0) ||
95 daemon->dhcp || daemon->doing_dhcp6)
96 inotify_dnsmasq_init();
97 @@ -802,7 +804,7 @@ int main (int argc, char **argv)
101 -#ifdef HAVE_LINUX_NETWORK
103 /* Using inotify, have to select a resolv file at startup */
104 poll_resolv(1, 0, now);
106 @@ -872,15 +874,18 @@ int main (int argc, char **argv)
107 bump_maxfd(daemon->icmp6fd, &maxfd);
111 -#if defined(HAVE_LINUX_NETWORK)
112 - FD_SET(daemon->netlinkfd, &rset);
113 - bump_maxfd(daemon->netlinkfd, &maxfd);
116 if (daemon->inotifyfd != -1)
118 FD_SET(daemon->inotifyfd, &rset);
119 bump_maxfd(daemon->inotifyfd, &maxfd);
123 +#if defined(HAVE_LINUX_NETWORK)
124 + FD_SET(daemon->netlinkfd, &rset);
125 + bump_maxfd(daemon->netlinkfd, &maxfd);
126 #elif defined(HAVE_BSD_NETWORK)
127 FD_SET(daemon->routefd, &rset);
128 bump_maxfd(daemon->routefd, &maxfd);
129 @@ -948,7 +953,7 @@ int main (int argc, char **argv)
133 -#ifdef HAVE_LINUX_NETWORK
135 if (daemon->inotifyfd != -1 && FD_ISSET(daemon->inotifyfd, &rset) && inotify_check(now))
137 if (daemon->port != 0 && !option_bool(OPT_NO_POLL))
138 @@ -1394,7 +1399,7 @@ void clear_cache_and_reload(time_t now)
139 if (option_bool(OPT_ETHERS))
142 -#ifdef HAVE_LINUX_NETWORK
146 dhcp_update_configs(daemon->dhcp_conf);
147 diff --git a/src/dnsmasq.h b/src/dnsmasq.h
148 index d841fdc064ad..8091634f69db 100644
151 @@ -544,7 +544,7 @@ struct resolvc {
152 int is_default, logged;
155 -#ifdef HAVE_LINUX_NETWORK
157 int wd; /* inotify watch descriptor */
158 char *file; /* pointer to file part if path */
160 @@ -558,7 +558,7 @@ struct hostsfile {
161 struct hostsfile *next;
164 -#ifdef HAVE_LINUX_NETWORK
166 int wd; /* inotify watch descriptor */
168 unsigned int index; /* matches to cache entries for logging */
169 @@ -1013,8 +1013,11 @@ extern struct daemon {
172 int dhcpfd, helperfd, pxefd;
176 #if defined(HAVE_LINUX_NETWORK)
177 - int netlinkfd, inotifyfd;
179 #elif defined(HAVE_BSD_NETWORK)
180 int dhcp_raw_fd, dhcp_icmp_fd, routefd;
182 @@ -1488,7 +1491,7 @@ int detect_loop(char *query, int type);
186 -#ifdef HAVE_LINUX_NETWORK
188 void inotify_dnsmasq_init();
189 int inotify_check(time_t now);
191 diff --git a/src/inotify.c b/src/inotify.c
192 index 52a30d7f44db..818fe8eddda4 100644
199 -#ifdef HAVE_LINUX_NETWORK
202 #include <sys/inotify.h>
204 @@ -216,5 +216,5 @@ static void check_for_dhcp_inotify(struct inotify_event *in, time_t now)
208 -#endif /* LINUX_NETWORK */
209 +#endif /* INOTIFY */