mirror of
https://github.com/matrix-construct/construct
synced 2024-11-15 14:31:11 +01:00
ircd::net::dns::cache: Add a mutex around the waiters list manipulations.
This commit is contained in:
parent
87fd0f04ea
commit
b28c5e0573
1 changed files with 21 additions and 6 deletions
|
@ -870,18 +870,33 @@ ircd::net::dns::cache::call_waiters(const string_view &type,
|
|||
const string_view &state_key,
|
||||
const json::array &rrs)
|
||||
{
|
||||
size_t ret(0);
|
||||
const ctx::uninterruptible::nothrow ui;
|
||||
|
||||
size_t ret(0), last; do
|
||||
{
|
||||
waiter *waiter {nullptr};
|
||||
auto it(begin(waiting));
|
||||
while(it != end(waiting))
|
||||
{
|
||||
auto &waiter(*it);
|
||||
if(call_waiter(type, state_key, rrs, waiter))
|
||||
waiter = std::addressof(*it);
|
||||
if(call_waiter(type, state_key, rrs, *waiter))
|
||||
break;
|
||||
|
||||
++it;
|
||||
}
|
||||
|
||||
last = ret;
|
||||
for(it = begin(waiting); it != end(waiting); ++it)
|
||||
{
|
||||
if(std::addressof(*it) != waiter)
|
||||
continue;
|
||||
|
||||
it = waiting.erase(it);
|
||||
++ret;
|
||||
break;
|
||||
}
|
||||
else ++it;
|
||||
}
|
||||
while(last > ret);
|
||||
|
||||
if(ret)
|
||||
dock.notify_all();
|
||||
|
|
Loading…
Reference in a new issue