when service pause for a long time, force invalidate cache after system resume

This commit is contained in:
Nick Peng
2019-03-31 01:37:01 +08:00
parent 2d01ed8a04
commit d9eb2a063d

View File

@@ -2222,8 +2222,22 @@ static void _dns_server_tcp_idle_check(void)
static void _dns_server_period_run_second(void)
{
static unsigned int sec = 0;
static time_t last = 0;
time_t now;
sec++;
time(&now);
if (last == 0) {
last = now;
}
if (now - 180 > last) {
dns_cache_invalidate(NULL, 0);
tlog(TLOG_WARN, "Service paused for 180s, force invalidate cache.");
}
last = now;
if (sec % 2 == 0) {
if (dns_conf_prefetch) {
/* do pre-fetching */