0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-06-11 14:38:57 +02:00

ircd::server: Fix conditions for link removal from link::close().

This commit is contained in:
Jason Volk 2018-03-04 01:22:05 -08:00
parent 90b7810921
commit c7ae8d3f27
2 changed files with 17 additions and 19 deletions

View file

@ -85,7 +85,7 @@ struct ircd::server::node
// control panel
void interrupt();
void close();
void close(const net::close_opts & = net::close_opts_default);
node();
~node() noexcept;

View file

@ -307,7 +307,7 @@ noexcept
}
void
ircd::server::node::close()
ircd::server::node::close(const net::close_opts &opts)
{
for(auto &link : this->links)
link.exclude = true;
@ -315,15 +315,12 @@ ircd::server::node::close()
std::vector<link *> links(this->links.size());
pointers(this->links, links);
for(const auto &link : links)
link->close(net::close_opts_default);
link->close(opts);
}
void
ircd::server::node::interrupt()
{
for(auto &link : links)
link.exclude = true;
for(auto &link : this->links)
link.cancel_all(std::make_exception_ptr(canceled
{
@ -764,16 +761,14 @@ catch(const std::bad_weak_ptr &)
}
catch(const std::exception &e)
{
if(wp.expired())
return;
assert(!wp.expired());
this->emsg = e.what();
this->etime = now<steady_point>();
close();
log.error("node(%p): during name resolution: %s",
this,
e.what());
close();
}
size_t
@ -1074,17 +1069,9 @@ ircd::server::link::handle_open(std::exception_ptr eptr)
bool
ircd::server::link::close(const net::close_opts &close_opts)
{
if(!socket)
return false;
if(fini)
return false;
auto handler
{
std::bind(&link::handle_close, this, ph::_1)
};
init = false;
fini = true;
@ -1100,6 +1087,17 @@ ircd::server::link::close(const net::close_opts &close_opts)
// link may be destroyed here
}};
auto handler
{
std::bind(&link::handle_close, this, ph::_1)
};
if(!socket)
{
handler(std::exception_ptr{});
return true;
}
net::close(*socket, close_opts, std::move(handler));
return true;
}