diff --git a/daemon/remote.c b/daemon/remote.c index 692479bb7..2058caeb4 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -760,6 +760,8 @@ print_stats(SSL* ssl, const char* nm, struct stats_info* s) (unsigned long)s->svr.num_queries_missed_cache)) return 0; if(!ssl_printf(ssl, "%s.num.prefetch"SQ"%lu\n", nm, (unsigned long)s->svr.num_queries_prefetch)) return 0; + if(!ssl_printf(ssl, "%s.num.zero_ttl"SQ"%lu\n", nm, + (unsigned long)s->svr.zero_ttl_responses)) return 0; if(!ssl_printf(ssl, "%s.num.recursivereplies"SQ"%lu\n", nm, (unsigned long)s->mesh_replies_sent)) return 0; if(!ssl_printf(ssl, "%s.requestlist.avg"SQ"%g\n", nm, diff --git a/daemon/stats.c b/daemon/stats.c index 838cf05ae..0687c0d24 100644 --- a/daemon/stats.c +++ b/daemon/stats.c @@ -251,6 +251,7 @@ void server_stats_add(struct stats_info* total, struct stats_info* a) total->svr.qEDNS += a->svr.qEDNS; total->svr.qEDNS_DO += a->svr.qEDNS_DO; total->svr.ans_rcode_nodata += a->svr.ans_rcode_nodata; + total->svr.zero_ttl_responses += a->svr.zero_ttl_responses; total->svr.ans_secure += a->svr.ans_secure; total->svr.ans_bogus += a->svr.ans_bogus; total->svr.rrset_bogus += a->svr.rrset_bogus; diff --git a/daemon/stats.h b/daemon/stats.h index 6985446ce..6c4178fc5 100644 --- a/daemon/stats.h +++ b/daemon/stats.h @@ -131,7 +131,8 @@ struct server_stats { size_t unwanted_queries; /** usage of tcp accept list */ size_t tcp_accept_usage; - + /** answers served from expired cache */ + size_t zero_ttl_responses; /** histogram data exported to array * if the array is the same size, no data is lost, and * if all histograms are same size (is so by default) then diff --git a/daemon/worker.c b/daemon/worker.c index 3c50567e4..d57c8b44d 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -563,6 +563,10 @@ answer_from_cache(struct worker* worker, struct query_info* qinfo, return 0; /* below, rrsets with ttl before timenow become TTL 0 in * the response */ + /* This response was served with zero TTL */ + if (timenow >= rep->ttl) { + worker->stats.zero_ttl_responses++; + } } else { /* see if it is possible */ if(rep->ttl < timenow) { diff --git a/doc/Changelog b/doc/Changelog index 4cea84ca7..b4653c4ea 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,7 @@ +28 October 2016: Wouter + - Patch for server.num.zero_ttl stats for count of expired replies, + from Pavel Odintsov. + 26 October 2016: Wouter - Fix unit tests for openssl 1.1, with no DSA, by faking DSA, enabled with the undocumented switch 'fake-dsa'. It logs a warning. diff --git a/doc/unbound-control.8.in b/doc/unbound-control.8.in index e7a18f47f..5a0bff682 100644 --- a/doc/unbound-control.8.in +++ b/doc/unbound-control.8.in @@ -316,6 +316,9 @@ and resulted in recursive processing, taking a slot in the requestlist. Not part of the recursivereplies (or the histogram thereof) or cachemiss, as a cache response was sent. .TP +.I threadX.num.zero_ttl +number of replies with ttl zero, because they served an expired cache entry. +.TP .I threadX.num.recursivereplies The number of replies sent to queries that needed recursive processing. Could be smaller than threadX.num.cachemiss if due to timeouts no replies were sent for some queries. .TP @@ -365,6 +368,9 @@ summed over threads. .I total.num.prefetch summed over threads. .TP +.I total.num.zero_ttl +summed over threads. +.TP .I total.num.recursivereplies summed over threads. .TP