diff --git a/modules/net_dns.cc b/modules/net_dns.cc index 3b7ba7026..ef2825a4c 100644 --- a/modules/net_dns.cc +++ b/modules/net_dns.cc @@ -129,8 +129,7 @@ ircd::net::dns::resolve(const hostport &hp, std::count_if(begin(cache::waiting), end(cache::waiting), [] (const auto &a) { - const auto &b(cache::waiting.back()); - return a.opts.qtype == b.opts.qtype && a.key == b.key; + return a == cache::waiting.back(); }) }; @@ -968,6 +967,24 @@ catch(const std::exception &e) // cache::waiter // +bool +ircd::net::dns::cache::operator==(const waiter &a, const waiter &b) +{ + return a.opts.qtype == b.opts.qtype && + a.key && b.key && + a.key == b.key; +} + +bool +ircd::net::dns::cache::operator!=(const waiter &a, const waiter &b) +{ + return !operator==(a, b); +} + +// +// cache::waiter::waiter +// + ircd::net::dns::cache::waiter::waiter(const hostport &hp, const dns::opts &opts, dns::callback &&callback) diff --git a/modules/net_dns.h b/modules/net_dns.h index cfcc93f31..db073150a 100644 --- a/modules/net_dns.h +++ b/modules/net_dns.h @@ -37,6 +37,9 @@ namespace ircd::net::dns::cache { struct waiter; + static bool operator==(const waiter &, const waiter &); + static bool operator!=(const waiter &, const waiter &); + static bool call_waiter(const string_view &, const string_view &, const json::array &, waiter &); static size_t call_waiters(const string_view &, const string_view &, const json::array &); static void handle(const m::event &, m::vm::eval &);