0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-09-27 19:28:52 +02:00

ircd::net::dns::resolver: Wait for all tags before net teardown on fini.

This commit is contained in:
Jason Volk 2019-09-19 12:57:52 -07:00
parent 083493dd1c
commit 26cd9cec85

View file

@ -132,37 +132,20 @@ ircd::net::dns::resolver::resolver(answers_callback callback)
ircd::net::dns::resolver::~resolver()
noexcept
{
log::debug
{
log, "Shutting down with %zu unfinished DNS resolutions.",
tags.size()
};
const ctx::uninterruptible::nothrow ui;
if(ns.is_open())
ns.close();
done.wait([this]
{
if(!tags.empty())
log::warning
{
log, "Waiting for %zu unfinished DNS resolutions",
log, "Waiting for %zu unfinished DNS resolutions...",
tags.size()
};
return tags.empty();
});
const std::lock_guard lock
{
mutex
};
timeout_context.terminate();
sendq_context.terminate();
recv_context.terminate();
assert(!mutex.locked());
assert(sendq.empty());
assert(tags.empty());
}
@ -306,7 +289,6 @@ catch(const std::out_of_range &e)
void
ircd::net::dns::resolver::timeout_worker()
try
{
while(1)
{
@ -318,16 +300,6 @@ try
check_timeouts(milliseconds(timeout));
}
}
catch(const ctx::terminated &)
{
const ctx::exception_handler eh;
const std::lock_guard lock
{
mutex
};
cancel_all();
}
void
ircd::net::dns::resolver::check_timeouts(const milliseconds &timeout)