[Dnsmasq-discuss] Dnsmasq not resolving addresses for an hour

John Knight John.Knight at belkin.com
Mon Oct 24 22:16:46 BST 2016


Hi All,

Here is the patch file I generated to fix the issue with poll_resolv that I was seeing with dnsmasq 2.55:

----------------- Begin Patch -------------
diff -Naur dnsmasq-2.55/src/dnsmasq.c dnsmasq-2.55_new/src/dnsmasq.c
--- dnsmasq-2.55/src/dnsmasq.c2016-10-20 10:43:23.609655958 -0700
+++ dnsmasq-2.55_new/src/dnsmasq.c2016-10-20 10:42:47.745654627 -0700
@@ -587,6 +587,14 @@ int main (int argc, char **argv)
   t.tv_usec = 250000;
   tp = &t;
 }
+     else
+{
+  /* we need to call poll_resolv at least once a second...
+     so we should not hang on select for more than a second */
+  t.tv_sec = 1;
+  t.tv_usec = 0;
+  tp = &t;
+}

 #ifdef HAVE_DBUS
       set_dbus_listeners(&maxfd, &rset, &wset, &eset);
@@ -904,7 +912,7 @@ void poll_resolv(int force, int do_reloa
 {
   struct resolvc *res, *latest;
   struct stat statbuf;
-  time_t last_change = 0;
+  static time_t last_change = 0;
   /* There may be more than one possible file.
      Go through and find the one which changed _last_.
      Warn of any which can't be read. */
@@ -939,8 +947,9 @@ void poll_resolv(int force, int do_reloa
 if (force || (statbuf.st_mtime != res->mtime))
           {
             res->mtime = statbuf.st_mtime;
-    if (difftime(statbuf.st_mtime, last_change) > 0.0)
+    if (difftime(statbuf.st_mtime, last_change) != 0.0)
       {
+        my_syslog(LOG_INFO, _("change detected for %s; time difference is %f"), res->name, difftime(statbuf.st_mtime, last_change));
 last_change = statbuf.st_mtime;
 latest = res;
       }
@@ -963,6 +972,8 @@ void poll_resolv(int force, int do_reloa
       else
 {
   latest->mtime = 0;
+  /* force reload next time poll_resolv is called */
+  last_change = 0;
   if (!warned)
     {
       my_syslog(LOG_WARNING, _("no servers found in %s, will retry"), latest->name);
__________________________________________________________________ Confidential This e-mail and any files transmitted with it are the property of Belkin International, Inc. and/or its affiliates, are confidential, and are intended solely for the use of the individual or entity to whom this e-mail is addressed. If you are not one of the named recipients or otherwise have reason to believe that you have received this e-mail in error, please notify the sender and delete this message immediately from your computer. Any other use, retention, dissemination, forwarding, printing or copying of this e-mail is strictly prohibited. Pour la version française: http://www.belkin.com/email-notice/French.html Für die deutsche Übersetzung: http://www.belkin.com/email-notice/German.html __________________________________________________________________
-------------- next part --------------
A non-text attachment was scrubbed...
Name: dnsmasq-2.55_017_poll_resolv.patch
Type: application/octet-stream
Size: 1682 bytes
Desc: dnsmasq-2.55_017_poll_resolv.patch
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20161024/d5429ab6/attachment.obj>


More information about the Dnsmasq-discuss mailing list