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

ircd: Support proper socket disconnect for SSL.

This commit is contained in:
Jason Volk 2017-08-23 15:49:33 -06:00
parent 144159c637
commit a32210a64d
2 changed files with 30 additions and 5 deletions

View file

@ -62,6 +62,8 @@ struct socket
FIN, // graceful shutdown both directions
FIN_SEND, // graceful shutdown send side
FIN_RECV, // graceful shutdown recv side
SSL_NOTIFY, // SSL close_notify (async, errors ignored)
SSL_NOTIFY_YIELD, // SSL close_notify (yields context, throws)
};
struct stat
@ -111,7 +113,7 @@ struct socket
void operator()(handler);
void cancel();
void disconnect(const dc &type = dc::FIN);
void disconnect(const dc &type = dc::SSL_NOTIFY);
void connect(const ip::tcp::endpoint &ep, const milliseconds &timeout = -1ms);
socket(const std::string &host,

View file

@ -175,6 +175,29 @@ ircd::socket::disconnect(const dc &type)
case dc::FIN: sd.shutdown(ip::tcp::socket::shutdown_both); break;
case dc::FIN_SEND: sd.shutdown(ip::tcp::socket::shutdown_send); break;
case dc::FIN_RECV: sd.shutdown(ip::tcp::socket::shutdown_receive); break;
case dc::SSL_NOTIFY:
{
ssl.async_shutdown([socket(shared_from_this())]
(boost::system::error_code ec)
{
if(!ec)
socket->sd.close(ec);
if(ec)
log::warning("socket(%p): disconnect(): %s",
socket.get(),
ec.message());
});
break;
}
case dc::SSL_NOTIFY_YIELD:
{
ssl.async_shutdown(yield(continuation()));
sd.close();
break;
}
}
}