From bf9ff021d0fd707f22306f61e0acc37d34c96f11 Mon Sep 17 00:00:00 2001 From: Otto Date: Mon, 2 Aug 2021 09:50:10 +0200 Subject: [PATCH] When using equal_range with a different compare function than the one used by the index, it should be consistent with the way the index is ordered. In particular PacketIDBirthdayCompare did not agree with operator< for PacketIDs --- pdns/pdns_recursor.cc | 7 ++----- pdns/syncres.hh | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 549b00bb4b..64d5ede01b 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -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 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 diff --git a/pdns/syncres.hh b/pdns/syncres.hh index ac08089d47..ae5a7e5dd5 100644 --- a/pdns/syncres.hh +++ b/pdns/syncres.hh @@ -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); } }; -- 2.47.2