0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-15 14:31:11 +01:00

ircd::net::dns: Improve cache waiting dup check.

This commit is contained in:
Jason Volk 2020-04-24 23:50:44 -07:00
parent fc14d4c825
commit 2556a18cdf

View file

@ -142,12 +142,13 @@ ircd::net::dns::resolve(const hostport &hp_,
// Remote query will be made; register this callback as waiting for reply // Remote query will be made; register this callback as waiting for reply
assert(cb); assert(cb);
const ctx::critical_assertion ca;
cache::waiting.emplace_back(hp, opts, std::move(cb)); cache::waiting.emplace_back(hp, opts, std::move(cb));
// Check if there is already someone else waiting on the same query // Check if there is already someone else waiting on the same query
const auto count const auto existing
{ {
std::count_if(begin(cache::waiting), end(cache::waiting), [] std::find_if(begin(cache::waiting), end(cache::waiting), []
(const auto &a) (const auto &a)
{ {
return a == cache::waiting.back(); return a == cache::waiting.back();
@ -155,8 +156,8 @@ ircd::net::dns::resolve(const hostport &hp_,
}; };
// When nobody else is already waiting on this query we have to submit it. // When nobody else is already waiting on this query we have to submit it.
assert(count >= 1); assert(existing != end(cache::waiting));
if(count == 1) if(*existing == cache::waiting.back())
resolver_call(hp, opts); resolver_call(hp, opts);
} }