0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-19 16:30:52 +01:00

ircd::net: Quick & likely success branch for these handlers.

This commit is contained in:
Jason Volk 2017-11-06 12:26:47 -08:00
parent 631991895b
commit 0df7ad850f

View file

@ -414,18 +414,17 @@ bool
ircd::net::listener::acceptor::accept_error(const error_code &ec, ircd::net::listener::acceptor::accept_error(const error_code &ec,
socket &sock) socket &sock)
{ {
using namespace boost::system::errc;
using boost::system::get_system_category; using boost::system::get_system_category;
if(unlikely(interrupting)) if(unlikely(interrupting))
throw ctx::interrupted(); throw ctx::interrupted();
if(likely(ec == success))
return false;
if(ec.category() == get_system_category()) switch(ec.value()) if(ec.category() == get_system_category()) switch(ec.value())
{ {
using namespace boost::system::errc;
case success:
return false;
case operation_canceled: case operation_canceled:
return false; return false;
@ -492,17 +491,16 @@ ircd::net::listener::acceptor::handshake_error(const error_code &ec,
socket &sock) socket &sock)
{ {
using boost::system::get_system_category; using boost::system::get_system_category;
using namespace boost::system::errc;
if(unlikely(interrupting)) if(unlikely(interrupting))
throw ctx::interrupted(); throw ctx::interrupted();
if(likely(ec == success))
return false;
if(ec.category() == get_system_category()) switch(ec.value()) if(ec.category() == get_system_category()) switch(ec.value())
{ {
using namespace boost::system::errc;
case success:
return false;
case operation_canceled: case operation_canceled:
return false; return false;
@ -1237,17 +1235,15 @@ ircd::net::socket::handle_error(const error_code &ec)
using boost::asio::error::get_ssl_category; using boost::asio::error::get_ssl_category;
using boost::asio::error::get_misc_category; using boost::asio::error::get_misc_category;
if(ec != success) if(likely(ec == success))
log.warning("socket(%p): handle error: %s: %s", return true;
this,
string(ec)); log.warning("socket(%p): handle error: %s: %s",
this,
string(ec));
if(ec.category() == get_system_category()) switch(ec.value()) if(ec.category() == get_system_category()) switch(ec.value())
{ {
// A success is not an error; can call the user handler
case success:
return true;
// A cancel is triggered either by the timeout handler or by // A cancel is triggered either by the timeout handler or by
// a request to shutdown/close the socket. We only call the user's // a request to shutdown/close the socket. We only call the user's
// handler for a timeout, otherwise this is hidden from the user. // handler for a timeout, otherwise this is hidden from the user.