hostip: do DNS cache pruning in milliseconds

Instead of using integer seconds. Also: if the cache contains over
30,000 entries after first pruning, it makes anoter round and removes
all entries that are older than half the age of the oldest entry until
it goes below 30,000.

Closes #18160
This commit is contained in:
Daniel Stenberg 2025-08-04 14:15:03 +02:00
parent be71475b13
commit 854b0e230c
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
6 changed files with 51 additions and 45 deletions

View file

@ -193,7 +193,7 @@ static CURLcode test_unit1607(const char *arg)
break;
}
if(dns->timestamp && tests[i].permanent) {
if(dns->timestamp.tv_sec && tests[i].permanent) {
curl_mfprintf(stderr,
"%s:%d tests[%d] failed. the timestamp is not zero "
"but tests[%d].permanent is TRUE\n",
@ -202,7 +202,7 @@ static CURLcode test_unit1607(const char *arg)
break;
}
if(dns->timestamp == 0 && !tests[i].permanent) {
if(dns->timestamp.tv_sec == 0 && !tests[i].permanent) {
curl_mfprintf(stderr, "%s:%d tests[%d] failed. the timestamp is zero "
"but tests[%d].permanent is FALSE\n",
__FILE__, __LINE__, i, i);