0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2024-11-29 02:02:38 +01:00

ircd::net: On disconnect, turn an EOF ec into a success.

This commit is contained in:
Jason Volk 2018-01-15 19:46:23 -08:00
parent 1e0fe2b3d5
commit 6682f0ce80
2 changed files with 7 additions and 2 deletions

View file

@ -66,7 +66,7 @@ struct ircd::net::socket
void call_user(const eptr_handler &, const error_code &) noexcept; void call_user(const eptr_handler &, const error_code &) noexcept;
void call_user(const ec_handler &, const error_code &) noexcept; void call_user(const ec_handler &, const error_code &) noexcept;
bool handle_verify(bool, asio::ssl::verify_context &, const open_opts &) noexcept; bool handle_verify(bool, asio::ssl::verify_context &, const open_opts &) noexcept;
void handle_disconnect(std::shared_ptr<socket>, eptr_handler, const error_code &) noexcept; void handle_disconnect(std::shared_ptr<socket>, eptr_handler, error_code) noexcept;
void handle_handshake(std::weak_ptr<socket>, eptr_handler, const error_code &) noexcept; void handle_handshake(std::weak_ptr<socket>, eptr_handler, const error_code &) noexcept;
void handle_connect(std::weak_ptr<socket>, open_opts, eptr_handler, const error_code &) noexcept; void handle_connect(std::weak_ptr<socket>, open_opts, eptr_handler, const error_code &) noexcept;
void handle_timeout(std::weak_ptr<socket>, ec_handler, const error_code &) noexcept; void handle_timeout(std::weak_ptr<socket>, ec_handler, const error_code &) noexcept;

View file

@ -1717,7 +1717,7 @@ catch(const std::exception &e)
void void
ircd::net::socket::handle_disconnect(std::shared_ptr<socket> s, ircd::net::socket::handle_disconnect(std::shared_ptr<socket> s,
eptr_handler callback, eptr_handler callback,
const error_code &ec) error_code ec)
noexcept try noexcept try
{ {
assert(!timedout || ec == boost::system::errc::operation_canceled); assert(!timedout || ec == boost::system::errc::operation_canceled);
@ -1731,6 +1731,11 @@ noexcept try
if(!timedout) if(!timedout)
cancel_timeout(); cancel_timeout();
// This ignores EOF and turns it into a success to alleviate user concern.
if(ec.category() == asio::error::get_misc_category())
if(ec.value() == asio::error::eof)
ec = error_code{};
sd.close(); sd.close();
call_user(callback, ec); call_user(callback, ec);
} }