0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-12-27 07:54:05 +01:00

ircd::net: Fix asio error code casting for SSL codes.

This commit is contained in:
Jason Volk 2017-11-16 22:02:57 -08:00
parent 0ef29fc433
commit 6b961711cb
2 changed files with 15 additions and 17 deletions

View file

@ -270,12 +270,10 @@ catch(const boost::system::system_error &e)
using boost::asio::error::get_ssl_category;
using boost::asio::error::get_misc_category;
const auto ec
{
e.code()
};
const error_code &ec{e.code()};
const int &value{ec.value()};
if(ec.category() == get_system_category()) switch(ec.value())
if(ec.category() == get_system_category()) switch(value)
{
case success:
assert(0);
@ -297,18 +295,18 @@ catch(const boost::system::system_error &e)
default:
break;
}
else if(ec.category() == get_misc_category()) switch(ec.value())
else if(ec.category() == get_ssl_category()) switch(uint8_t(value))
{
case boost::asio::error::eof:
case SSL_R_SHORT_READ:
disconnect(*this, net::dc::RST);
return false;
default:
break;
}
else if(ec.category() == get_ssl_category()) switch(ec.value())
else if(ec.category() == get_misc_category()) switch(value)
{
case SSL_R_SHORT_READ:
case boost::asio::error::eof:
disconnect(*this, net::dc::RST);
return false;
@ -319,7 +317,7 @@ catch(const boost::system::system_error &e)
log::error("client(%p): (unexpected) %s: (%d) %s",
(const void *)this,
ec.category().name(),
int{ec.value()},
value,
ec.message());
disconnect(*this, net::dc::RST);

View file

@ -1271,20 +1271,20 @@ ircd::net::socket::handle_error(const error_code &ec)
default:
return true;
}
else if(ec.category() == get_misc_category()) switch(ec.value())
else if(ec.category() == get_ssl_category()) switch(uint8_t(ec.value()))
{
// This indicates the remote closed the socket, we still
// pass this up to the user so they can know that too.
case boost::asio::error::eof:
// Docs say this means we read less bytes off the socket than desired.
case SSL_R_SHORT_READ:
return true;
default:
return true;
}
else if(ec.category() == get_ssl_category()) switch(ec.value())
else if(ec.category() == get_misc_category()) switch(ec.value())
{
// Docs say this means we read less bytes off the socket than desired.
case SSL_R_SHORT_READ:
// This indicates the remote closed the socket, we still
// pass this up to the user so they can know that too.
case boost::asio::error::eof:
return true;
default: