Browse Source

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

Nick Peng 6 years ago
parent
commit
d9eb2a063d
1 changed files with 14 additions and 0 deletions
  1. 14 0
      src/dns_server.c

+ 14 - 0
src/dns_server.c

@@ -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 */