0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2025-02-16 16:50:12 +01:00

ircd::server: Improve this error information.

This commit is contained in:
Jason Volk 2019-03-01 10:07:56 -08:00
parent 8fee82b0d6
commit 62d33e2f7a

View file

@ -1764,6 +1764,7 @@ ircd::server::link::read(const mutable_buffer &buf)
void
ircd::server::link::discard_read()
{
assert(socket);
ssize_t discard
{
SSL_pending(socket->ssl.native_handle())
@ -1785,25 +1786,35 @@ ircd::server::link::discard_read()
// Shouldn't ever be hit because the read() within discard() throws
// the pending error like an eof.
log::warning
const fmt::snstringf msg
{
log, "link(%p) socket(%p) to %s discarded %zu of %zd unexpected bytes",
512, "peer(%p %s) link(%p q:%zu) socket(%s) discarded %zu of %zd unexpected bytes",
peer,
peer?
peer->hostcanon:
std::string{},
this,
socket.get(),
likely(peer)? string(peer->remote) : string(remote_ipport(*socket)),
queue.size(),
likely(peer)?
string(peer->remote):
socket?
string(remote_ipport(*socket)):
std::string{},
discarded,
discard
};
log::warning
{
log, "%s", string_view{msg}
};
// just in case so this doesn't get loopy with discarding zero with
// an empty queue...
if(unlikely(!discard && !discarded))
throw panic
{
"peer(%p) link(%p) socket(%p) queue is empty and nothing to discard.",
peer,
this,
socket.get()
"%s", string_view{msg}
};
}