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

ircd::net/ircd::server/ircd::client: Various cleanup; log messages.

This commit is contained in:
Jason Volk 2018-08-28 11:48:09 -07:00
parent 111bf3b717
commit 2b199ae3ed
3 changed files with 103 additions and 64 deletions

View file

@ -117,6 +117,11 @@ noexcept
close();
wait();
log::debug
{
"All client contexts, connections, and requests are clear.",
};
assert(client::list.empty());
}
@ -217,10 +222,6 @@ ircd::client::wait_all()
};
context.join();
log::debug
{
"All client contexts, connections, and requests are clear.",
};
}
ircd::parse::read_closure
@ -412,10 +413,13 @@ try
client->reqctx = nullptr;
}};
if(client->main())
client->async();
else
if(!client->main())
{
client->close(net::dc::SSL_NOTIFY).wait();
return;
}
client->async();
}
catch(const std::exception &e)
{

View file

@ -1824,13 +1824,16 @@ try
return;
}
log.debug("socket(%p) local[%s] remote[%s] disconnect type:%d user: in:%zu out:%zu",
(const void *)this,
string(local_ipport(*this)),
string(remote_ipport(*this)),
uint(opts.type),
in.bytes,
out.bytes);
log::debug
{
log, "socket(%p) local[%s] remote[%s] disconnect type:%d user: in:%zu out:%zu",
(const void *)this,
string(local_ipport(*this)),
string(remote_ipport(*this)),
uint(opts.type),
in.bytes,
out.bytes
};
assert(!fini);
fini = true;
@ -1874,6 +1877,14 @@ try
}
catch(const boost::system::system_error &e)
{
log::derror
{
log, "socket(%p) disconnect type:%d :%s",
(const void *)this,
uint(opts.type),
e.what()
};
call_user(callback, e.code());
}
catch(const std::exception &e)

View file

@ -40,6 +40,49 @@ close_all_timeout
{ "default", 2L },
};
//
// init
//
ircd::server::init::init()
{
}
ircd::server::init::~init()
noexcept
{
close();
wait();
peers.clear();
log::debug
{
log, "All server peers, connections, and requests are clear."
};
}
void
ircd::server::init::wait()
{
wait_all();
}
void
ircd::server::init::close()
{
close_all();
}
void
ircd::server::init::interrupt()
{
interrupt_all();
}
//
// server
//
void
ircd::server::wait_all()
{
@ -48,23 +91,28 @@ ircd::server::wait_all()
if(dock.wait_for(seconds(2)))
continue;
log.warning("Waiting for %zu tags on %zu links on %zu of %zu peers to close...",
tag_count(),
link_count(),
peer_unfinished(),
peer_count());
log::warning
{
log, "Waiting for %zu tags on %zu links on %zu of %zu peers to close...",
tag_count(),
link_count(),
peer_unfinished(),
peer_count()
};
}
}
void
ircd::server::close_all()
{
log.debug("Closing all %zu peers",
peer_count());
log::debug
{
log, "Closing all %zu peers",
peer_count()
};
net::close_opts opts;
opts.timeout = seconds(close_all_timeout);
for(auto &peer : peers)
peer.second->close(opts);
}
@ -72,10 +120,13 @@ ircd::server::close_all()
void
ircd::server::interrupt_all()
{
log.debug("Interrupting %zu tags on %zu links on %zu peers",
tag_count(),
link_count(),
peer_count());
log::debug
{
log, "Interrupting %zu tags on %zu links on %zu peers",
tag_count(),
link_count(),
peer_count()
};
for(auto &peer : peers)
peer.second->cancel();
@ -93,10 +144,17 @@ ircd::server::get(const net::hostport &hostport)
auto it(peers.lower_bound(canonized));
if(it == peers.end() || it->first != canonized)
{
auto peer{create(hostport)};
log.debug("peer(%p) for %s created; adding...",
peer.get(),
canonized);
auto peer
{
create(hostport)
};
log::debug
{
log, "peer(%p) for %s created; adding...",
peer.get(),
canonized
};
const string_view key{peer->hostname};
it = peers.emplace_hint(it, key, std::move(peer));
@ -240,40 +298,6 @@ ircd::server::accumulate_peers(F&& closure)
});
}
//
// init
//
ircd::server::init::init()
{
}
ircd::server::init::~init()
noexcept
{
close();
wait();
peers.clear();
}
void
ircd::server::init::wait()
{
wait_all();
}
void
ircd::server::init::close()
{
close_all();
}
void
ircd::server::init::interrupt()
{
interrupt_all();
}
///
// request
//