diff options
author | 袁建鹏 <yuanjianpeng@xiaomi.com> | 2022-04-18 15:25:54 +0100 |
---|---|---|
committer | Simon Kelley <simon@thekelleys.org.uk> | 2022-04-18 15:25:54 +0100 |
commit | 1a98d1a94fbc920e5f01bad5fe95b4766e5f661e (patch) | |
tree | 5eb40de72689fca2f3ab45e99b384272c23a40d6 | |
parent | 03345ecefeb0d82e3c3a4c28f27c3554f0611b39 (diff) | |
download | dnsmasq-1a98d1a94fbc920e5f01bad5fe95b4766e5f661e.tar.gz |
Add inode compare while checking resolv file change
Fix a bug found on OpenWrt when IPv4/6 dual stack enabled:
The resolv file is located on tmpfs whose mtime resolution
is 1 second. If the resolv file is updated twice within one
second dnsmasq may can't notice the second update.
netifd updates the resolv file with method: write temp then move,
so adding an inode check fixes this bug.
-rw-r--r-- | src/dnsmasq.c | 3 | ||||
-rw-r--r-- | src/dnsmasq.h | 1 |
2 files changed, 3 insertions, 1 deletions
diff --git a/src/dnsmasq.c b/src/dnsmasq.c index 7cfb493..858c731 100644 --- a/src/dnsmasq.c +++ b/src/dnsmasq.c @@ -1665,9 +1665,10 @@ static void poll_resolv(int force, int do_reload, time_t now) else { res->logged = 0; - if (force || (statbuf.st_mtime != res->mtime)) + if (force || (statbuf.st_mtime != res->mtime || statbuf.st_ino != res->ino)) { res->mtime = statbuf.st_mtime; + res->ino = statbuf.st_ino; if (difftime(statbuf.st_mtime, last_change) > 0.0) { last_change = statbuf.st_mtime; diff --git a/src/dnsmasq.h b/src/dnsmasq.h index bfc0fd4..0c21cde 100644 --- a/src/dnsmasq.h +++ b/src/dnsmasq.h @@ -665,6 +665,7 @@ struct resolvc { struct resolvc *next; int is_default, logged; time_t mtime; + ino_t ino; char *name; #ifdef HAVE_INOTIFY int wd; /* inotify watch descriptor */ |