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

John Knight John.Knight at belkin.com
Fri Oct 14 02:17:49 BST 2016


Hi All,

Well, I believe I have found another issue with the function poll_resolv().  The variable last_change needs to be static.  Otherwise, the difftime(statbuf.st_mtime, last_change) always is a rather large number... the number of seconds since time 0 (the initialized value of last_change at the top of the function).  By making this variable static, the last_change truly becomes the elapsed time in seconds since the last change for /etc/resolv.conf.  The last_change variable really represents the timestamp of when reload_servers() was called last.

To see the issue, I added a my_syslog to log that a change is detected and what the time difference is:

     if (force || (statbuf.st_mtime != res->mtime))
          {
            res->mtime = statbuf.st_mtime;

            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;
         }
       }
      }

Without the static for last_change variable, the time difference reported is rather large... number of seconds since epoch (0).
static time_t last_change = 0;

I added the static in the above statement at the top of the function.

John

__________________________________________________________________ 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 --------------
An HTML attachment was scrubbed...
URL: <http://lists.thekelleys.org.uk/pipermail/dnsmasq-discuss/attachments/20161014/42b99e33/attachment.html>


More information about the Dnsmasq-discuss mailing list