From 03034723df124190ca148f53e9eb5a80e7a903e9 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 27 Feb 2018 17:20:31 -0800 Subject: [PATCH] ircd::net: Update socket handler conditions to ignore timeout if data is there too. --- ircd/net.cc | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/ircd/net.cc b/ircd/net.cc index c21f028f7..c007a70ab 100644 --- a/ircd/net.cc +++ b/ircd/net.cc @@ -1534,10 +1534,10 @@ noexcept try if(!timedout) cancel_timeout(); - else + else if(ec == operation_canceled && ec.category() == system_category()) ec = { timed_out, system_category() }; - if(!ec && !sd.is_open()) + if(unlikely(!ec && !sd.is_open())) ec = { bad_file_descriptor, system_category() }; log.debug("socket(%p) local[%s] remote[%s] ready %s %s available:%zu", @@ -1652,12 +1652,10 @@ noexcept try string(ec)); // The timer was set by socket::connect() and may need to be canceled. - if(timedout) - { - assert(ec == operation_canceled); + if(!timedout) + cancel_timeout(); + else if(ec == operation_canceled && ec.category() == system_category()) ec = { timed_out, system_category() }; - } - else cancel_timeout(); // A connect error; abort here by calling the user back with error. if(ec) @@ -1713,12 +1711,10 @@ noexcept try using namespace boost::system::errc; using boost::system::system_category; - if(timedout) - { - assert(ec == operation_canceled); + if(!timedout) + cancel_timeout(); + else if(ec == operation_canceled && ec.category() == system_category()) ec = { timed_out, system_category() }; - } - else cancel_timeout(); log.debug("socket(%p) local[%s] remote[%s] disconnect %s", this, @@ -1764,12 +1760,10 @@ noexcept try const life_guard s{wp}; - if(timedout) - { - assert(ec == operation_canceled); + if(!timedout) + cancel_timeout(); + else if(ec == operation_canceled && ec.category() == system_category()) ec = { timed_out, system_category() }; - } - else cancel_timeout(); log.debug("socket(%p) local[%s] remote[%s] handshake %s", this,