From b049c29be790c36908dbe9d26a0720f2b0909ff3 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Tue, 8 Dec 2015 09:55:45 +0100 Subject: [PATCH] make grepq look at the the n newest queries, not the n oldest queries --- pdns/dnsdist-lua2.cc | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pdns/dnsdist-lua2.cc b/pdns/dnsdist-lua2.cc index 90c9daafd..9c036ecb2 100644 --- a/pdns/dnsdist-lua2.cc +++ b/pdns/dnsdist-lua2.cc @@ -218,14 +218,22 @@ void moreLua() ReadLock rl(&g_rings.queryLock); qr=g_rings.queryRing; } + sort(qr.begin(), qr.end(), [](const decltype(qr)::value_type& a, const decltype(qr)::value_type& b) { + return b.when < a.when; + }); { std::lock_guard lock(g_rings.respMutex); rr=g_rings.respRing; } + + sort(rr.begin(), rr.end(), [](const decltype(rr)::value_type& a, const decltype(rr)::value_type& b) { + return b.when < a.when; + }); unsigned int num=0; struct timespec now; clock_gettime(CLOCK_MONOTONIC, &now); + std::multimap out; for(const auto& c : qr) { if((nm && nm->match(c.requestor)) || (dn && c.name.isPartOf(*dn))) { -- 2.40.0