]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
When using equal_range with a different compare function than the one used by the...
authorOtto <otto.moerbeek@open-xchange.com>
Mon, 2 Aug 2021 07:50:10 +0000 (09:50 +0200)
committerOtto <otto.moerbeek@open-xchange.com>
Mon, 2 Aug 2021 12:56:49 +0000 (14:56 +0200)
should be consistent with the way the index is ordered.

In particular PacketIDBirthdayCompare did not agree with operator< for PacketIDs

pdns/pdns_recursor.cc
pdns/syncres.hh

index 549b00bb4b1d27e0510d31ed0ca4c555ec846272..64d5ede01b6d287daf7bb5c8810f2ad2a3454183 100644 (file)
@@ -399,7 +399,7 @@ static bool isHandlerThread()
   return s_threadInfos.at(t_id).isHandler;
 }
 
-#if 1
+#if 0
 #define TCPLOG(tcpsock, x) do { cerr << [](){ timeval t; gettimeofday(&t, nullptr); return t.tv_sec % 10  + t.tv_usec/1000000.0; }() << " FD " << (tcpsock) << ' ' << x; } while (0)
 #else
 #define TCPLOG(pid, x)
@@ -741,11 +741,8 @@ LWResult::Result asendto(const char *data, size_t len, int flags,
   pair<MT_t::waiters_t::iterator, MT_t::waiters_t::iterator> chain=MT->d_waiters.equal_range(pident, PacketIDBirthdayCompare());
 
   for(; chain.first != chain.second; chain.first++) {
+    // Line below detected an issue with the two ways of ordering PackeIDs (birtday and non-birthday)
     assert(chain.first->key->domain == pident->domain);
-    if (chain.first->key->domain != pident->domain) {
-      // XXX Actually, this should not happen..., but it does
-      continue;
-    }
     if(chain.first->key->fd > -1 && !chain.first->key->closed) { // don't chain onto existing chained waiter or a chain already processed
       //cerr << "Insert " << id << ' ' << pident << " into chain for  " << chain.first->key << endl;
       chain.first->key->chain.insert(id); // we can chain
index ac08089d4706709543ef4383e201dffed81693f9..ae5a7e5dd501f4b2dc563cd2feeaf8ea28271af4 100644 (file)
@@ -974,7 +974,7 @@ struct PacketID
       return false;
     }
 
-    return tie(fd, id, domain) < tie(b.fd, b.id, b.domain);
+    return tie(domain, fd, id) < tie(b.domain, b.fd, b.id);
   }
 };