From 011842775f750711833526d5bba1b818713947f5 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 11 Jan 2016 18:57:59 +0100 Subject: resolved: split out resetting of DNS server counters into a function call of its own A suggested by Vito Caputo: https://github.com/systemd/systemd/pull/2289#discussion-diff-49276220 --- src/resolve/resolved-dns-server.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/resolve/resolved-dns-server.c b/src/resolve/resolved-dns-server.c index 2a0301aa49..0969e31e8a 100644 --- a/src/resolve/resolved-dns-server.c +++ b/src/resolve/resolved-dns-server.c @@ -344,6 +344,16 @@ static bool dns_server_grace_period_expired(DnsServer *s) { return true; } +static void dns_server_reset_counters(DnsServer *s) { + assert(s); + + s->n_failed_udp = 0; + s->n_failed_tcp = 0; + s->packet_failed = false; + s->packet_truncated = false; + s->verified_usec = 0; +} + DnsServerFeatureLevel dns_server_possible_feature_level(DnsServer *s) { assert(s); @@ -351,13 +361,10 @@ DnsServerFeatureLevel dns_server_possible_feature_level(DnsServer *s) { dns_server_grace_period_expired(s)) { s->possible_feature_level = DNS_SERVER_FEATURE_LEVEL_BEST; - s->n_failed_udp = 0; - s->n_failed_tcp = 0; - s->packet_failed = false; - s->packet_truncated = false; - s->verified_usec = 0; s->rrsig_missing = false; + dns_server_reset_counters(s); + log_info("Grace period over, resuming full feature set (%s) for DNS server %s", dns_server_feature_level_to_string(s->possible_feature_level), dns_server_string(s)); @@ -405,11 +412,7 @@ DnsServerFeatureLevel dns_server_possible_feature_level(DnsServer *s) { if (p != s->possible_feature_level) { /* We changed the feature level, reset the counting */ - s->n_failed_udp = 0; - s->n_failed_tcp = 0; - s->packet_failed = false; - s->packet_truncated = false; - s->verified_usec = 0; + dns_server_reset_counters(s); log_warning("Using degraded feature set (%s) for DNS server %s", dns_server_feature_level_to_string(s->possible_feature_level), -- cgit v1.2.3-54-g00ecf