diff options
author | Simon Kelley <simon@thekelleys.org.uk> | 2022-10-30 15:40:20 +0000 |
---|---|---|
committer | Simon Kelley <simon@thekelleys.org.uk> | 2022-10-30 15:40:20 +0000 |
commit | d3c21c596ef96027429b11216fcdbf65c9434afa (patch) | |
tree | c46e979150db134a39349ac5e8b9a088d76beecd | |
parent | 34fac952b6e60f43671cf66b1e553f6196a218ae (diff) | |
download | dnsmasq-d3c21c596ef96027429b11216fcdbf65c9434afa.tar.gz |
Reconcile "names" and "address" counts when reading hostfiles.
-rw-r--r-- | src/cache.c | 10 | ||||
-rw-r--r-- | src/inotify.c | 2 |
2 files changed, 6 insertions, 6 deletions
diff --git a/src/cache.c b/src/cache.c index f8c4b2c..119cf9f 100644 --- a/src/cache.c +++ b/src/cache.c @@ -189,7 +189,7 @@ static void rehash(int size) else if (new_size <= hash_size || !(new = whine_malloc(new_size * sizeof(struct crec *)))) return; - for(i = 0; i < new_size; i++) + for (i = 0; i < new_size; i++) new[i] = NULL; old = hash_table; @@ -1169,7 +1169,7 @@ int read_hostsfile(char *filename, unsigned int index, int cache_size, struct cr { FILE *f = fopen(filename, "r"); char *token = daemon->namebuff, *domain_suffix = NULL; - int addr_count = 0, name_count = cache_size, lineno = 1; + int names_done = 0, name_count = cache_size, lineno = 1; unsigned int flags = 0; union all_addr addr; int atnl, addrlen = 0; @@ -1205,8 +1205,6 @@ int read_hostsfile(char *filename, unsigned int index, int cache_size, struct cr continue; } - addr_count++; - /* rehash every 1000 names. */ if (rhash && ((name_count - cache_size) > 1000)) { @@ -1238,6 +1236,7 @@ int read_hostsfile(char *filename, unsigned int index, int cache_size, struct cr cache->ttd = daemon->local_ttl; add_hosts_entry(cache, &addr, addrlen, index, rhash, hashsz); name_count++; + names_done++; } if ((cache = whine_malloc(SIZEOF_BARE_CREC + strlen(canon) + 1))) { @@ -1246,6 +1245,7 @@ int read_hostsfile(char *filename, unsigned int index, int cache_size, struct cr cache->ttd = daemon->local_ttl; add_hosts_entry(cache, &addr, addrlen, index, rhash, hashsz); name_count++; + names_done++; } free(canon); @@ -1262,7 +1262,7 @@ int read_hostsfile(char *filename, unsigned int index, int cache_size, struct cr if (rhash) rehash(name_count); - my_syslog(LOG_INFO, _("read %s - %d addresses"), filename, addr_count); + my_syslog(LOG_INFO, _("read %s - %d names"), filename, names_done); return name_count; } diff --git a/src/inotify.c b/src/inotify.c index cc6d7bd..d3c8277 100644 --- a/src/inotify.c +++ b/src/inotify.c @@ -306,7 +306,7 @@ int inotify_check(time_t now) { const unsigned int removed = cache_remove_uid(ah->index); if (removed > 0) - my_syslog(LOG_INFO, _("inotify: flushed %u addresses read from %s"), removed, path); + my_syslog(LOG_INFO, _("inotify: flushed %u names read from %s"), removed, path); /* (Re-)load hostsfile only if this event isn't triggered by deletion */ if (!(in->mask & IN_DELETE)) |