Enhance --hostdir so that records are automatically removed when re-reading.

Initial patch from Dominik Derigs, re-written by Simon Kelley.
This commit is contained in:
Dominik Derigs
2022-10-16 22:08:45 +01:00
committed by Simon Kelley
parent 0ba25a0512
commit 0017dd74d5
5 changed files with 33 additions and 2 deletions

View File

@@ -388,6 +388,27 @@ static int is_expired(time_t now, struct crec *crecp)
return 1;
}
/* Remove entries with a given UID from the cache */
unsigned int cache_remove_uid(const unsigned int uid)
{
int i;
unsigned int removed = 0;
struct crec *crecp, **up;
for (i = 0; i < hash_size; i++)
for (crecp = hash_table[i], up = &hash_table[i]; crecp; crecp = crecp->hash_next)
if ((crecp->flags & (F_HOSTS | F_DHCP | F_CONFIG)) && crecp->uid == uid)
{
*up = crecp->hash_next;
free(crecp);
removed++;
}
else
up = &crecp->hash_next;
return removed;
}
static struct crec *cache_scan_free(char *name, union all_addr *addr, unsigned short class, time_t now,
unsigned int flags, struct crec **target_crec, unsigned int *target_uid)
{