From: bert hubert Date: Mon, 4 Jan 2016 23:17:18 +0000 (+0100) Subject: make sure dnsdist updates 'downstream-timeouts' metric properly X-Git-Tag: dnsdist-1.0.0-alpha2~126 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c2fbeb276539970058cf56872b3075300016fe1d;p=pdns make sure dnsdist updates 'downstream-timeouts' metric properly --- diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 54e71897c..d71f4caa6 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -830,16 +830,21 @@ void* maintThread() for(IDState& ids : dss->idStates) { // timeouts if(ids.origFD >=0 && ids.age++ > 2) { ids.age = 0; - ids.origFD = -1; dss->reuseds++; --dss->outstanding; - struct timespec ts; - clock_gettime(CLOCK_MONOTONIC, &ts); - std::lock_guard lock(g_rings.respMutex); + struct timespec ts; + clock_gettime(CLOCK_MONOTONIC, &ts); + struct dnsheader fake; memset(&fake, 0, sizeof(fake)); fake.id = ids.origID; - g_rings.respRing.push_back({ts, ids.origRemote, ids.qname, ids.qtype, std::numeric_limits::max(), 0, fake, dss->remote}); + + std::lock_guard lock(g_rings.respMutex); + g_rings.respRing.push_back({ts, ids.origRemote, ids.qname, ids.qtype, std::numeric_limits::max(), 0, fake, dss->remote}); + g_stats.downstreamTimeouts++; // this is an 'actively' discovered timeout + // we keep track of 'reuseds' seperately + + ids.origFD = -1; // don't touch 'ids' beyond this point! } } }