]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Merge pull request #14773 from omoerbeek/backport-14628-to-rec-5.1.x
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Thu, 24 Oct 2024 06:26:35 +0000 (08:26 +0200)
committerGitHub <noreply@github.com>
Thu, 24 Oct 2024 06:26:35 +0000 (08:26 +0200)
rec: Backport 14628 to rec 5.1.x: rec: avoid duplicated waiter ids for chained requests

1  2 
pdns/recursordist/pdns_recursor.cc

index e636cf57a86f1deae8b5bf01fe85bd38d6a9a82c,4f5f26046ac8e562505b30138f8b3339f3707280..3aed8c4fcdb86d8deb162ea1f1911db0fd6e464d
@@@ -305,17 -305,17 +305,17 @@@ LWResult::Result asendto(const void* da
        assert(chain.first->key->domain == pident->domain); // NOLINT
        // don't chain onto existing chained waiter or a chain already processed
        if (chain.first->key->fd > -1 && !chain.first->key->closed) {
-         *fileDesc = -1; // gets used in waitEvent / sendEvent later on
          auto currentChainSize = chain.first->key->authReqChain.size();
+         *fileDesc = -static_cast<int>(currentChainSize + 1); // value <= -1, gets used in waitEvent / sendEvent later on
          if (g_maxChainLength > 0 && currentChainSize >= g_maxChainLength) {
 -          return LWResult::Result::OSLimitError;
 +          return LWResult::Result::ChainLimitError;
          }
          assert(uSec(chain.first->key->creationTime) != 0); // NOLINT
          auto age = now - chain.first->key->creationTime;
          if (uSec(age) > static_cast<uint64_t>(1000) * authWaitTimeMSec(g_multiTasker) * 2 / 3) {
 -          return LWResult::Result::OSLimitError;
 +          return LWResult::Result::ChainLimitError;
          }
-         chain.first->key->authReqChain.insert(qid); // we can chain
+         chain.first->key->authReqChain.emplace(*fileDesc, qid); // we can chain
          auto maxLength = t_Counters.at(rec::Counter::maxChainLength);
          if (currentChainSize > maxLength) {
            t_Counters.at(rec::Counter::maxChainLength) = currentChainSize;