]> granicus.if.org Git - pdns/commitdiff
make grepq look at the the n newest queries, not the n oldest queries
authorbert hubert <bert.hubert@netherlabs.nl>
Tue, 8 Dec 2015 08:55:45 +0000 (09:55 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Tue, 8 Dec 2015 08:55:45 +0000 (09:55 +0100)
pdns/dnsdist-lua2.cc

index 90c9daafd48d6ec108e5b7471f961ab66de5cf18..9c036ecb259ba17076140c7b1d37810ce73a6eff 100644 (file)
@@ -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<std::mutex> 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<struct timespec, string> out;
       for(const auto& c : qr) {
         if((nm && nm->match(c.requestor)) || (dn && c.name.isPartOf(*dn)))  {