0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-02 10:08:56 +02:00

ircd::net::dns::cache: Add equality operations for waiter.

This commit is contained in:
Jason Volk 2019-09-12 10:58:55 -07:00
parent 3157aa5405
commit d3039669f5
2 changed files with 22 additions and 2 deletions

View file

@ -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)

View file

@ -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 &);