mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 10:18:25 +00:00
Reconcile "names" and "address" counts when reading hostfiles.
This commit is contained in:
10
src/cache.c
10
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;
|
||||
}
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user