From d1fba58e3a01749953556aad65f0bdfad01384b9 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Tue, 17 Nov 2015 16:01:53 +0100 Subject: [PATCH] make dnsdist like faster servers even more in leastOutstanding policy (which also appears to honor the 'order' field!) --- pdns/dnsdist.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 38d266936..b1b5d5cbc 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -239,13 +239,16 @@ shared_ptr firstAvailable(const NumberedServerVector& servers, return leastOutstanding(servers, remote, qname, qtype, dh); } +// get server with least outstanding queries, and within those, with the lowest order, and within those: the fastest shared_ptr leastOutstanding(const NumberedServerVector& servers, const ComboAddress& remote, const DNSName& qname, uint16_t qtype, dnsheader* dh) { - vector, shared_ptr>> poss; + vector, shared_ptr>> poss; + /* so you might wonder, why do we go through this trouble? The data on which we sort could change during the sort, + which would suck royally and could even lead to crashes. So first we snapshot on what we sort, and then we sort */ poss.reserve(servers.size()); for(auto& d : servers) { if(d.second->isUp()) { - poss.push_back({make_pair(d.second->outstanding.load(), d.second->order), d.second}); + poss.push_back({make_tuple(d.second->outstanding.load(), d.second->order, d.second->latencyUsec), d.second}); } } if(poss.empty()) -- 2.40.0