Only recycle domains when their last query was more than 24 hours ago.

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2024-10-19 16:10:15 +02:00
parent 1d99b6f988
commit 3f4bc0e2ba
+11
View File
@@ -53,6 +53,10 @@ bool doGC = false;
// by any query (only head and tail of the CNAME chain are)
static void recycle(void)
{
// Get current time
const double twentyfour_hrs_ago = double_time() - 24*3600;
// Allocate memory for recycling
bool *client_used = calloc(counters->clients, sizeof(bool));
bool *domain_used = calloc(counters->domains, sizeof(bool));
bool *cache_used = calloc(counters->dns_cache_size, sizeof(bool));
@@ -122,6 +126,13 @@ static void recycle(void)
if(domain == NULL)
continue;
// Only recycle domains when their last query was more than 24
// hours ago. This ensures that we do not recycle domains that
// have recently been seen but which are not part of any query
// (e.g., intermediate domains during CNAME inspection)
if(domain->lastQuery > twentyfour_hrs_ago)
continue;
log_debug(DEBUG_GC, "Recycling domain %s (ID %u, lastQuery at %.3f)",
getstr(domain->domainpos), domainID, domain->lastQuery);