mirror of
https://github.com/CrowCpp/Crow.git
synced 2024-06-07 21:10:44 +00:00
shutting down socket before closing the connection
This commit is contained in:
parent
745f6c95c6
commit
63ea212e1a
@ -518,6 +518,7 @@ namespace crow
|
||||
{
|
||||
cancel_deadline_timer();
|
||||
parser_.done();
|
||||
adaptor_.shutdown_read();
|
||||
adaptor_.close();
|
||||
is_reading = false;
|
||||
CROW_LOG_DEBUG << this << " from read(1)";
|
||||
@ -558,6 +559,7 @@ namespace crow
|
||||
{
|
||||
if (close_connection_)
|
||||
{
|
||||
adaptor_.shutdown_write();
|
||||
adaptor_.close();
|
||||
CROW_LOG_DEBUG << this << " from write(1)";
|
||||
check_destroy();
|
||||
@ -597,6 +599,7 @@ namespace crow
|
||||
{
|
||||
return;
|
||||
}
|
||||
adaptor_.shutdown_readwrite();
|
||||
adaptor_.close();
|
||||
});
|
||||
CROW_LOG_DEBUG << this << " timer added: " << timer_cancel_key_.first << ' ' << timer_cancel_key_.second;
|
||||
|
@ -53,6 +53,24 @@ namespace crow
|
||||
socket_.close(ec);
|
||||
}
|
||||
|
||||
void shutdown_readwrite()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
socket_.shutdown(boost::asio::socket_base::shutdown_type::shutdown_both, ec);
|
||||
}
|
||||
|
||||
void shutdown_write()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
socket_.shutdown(boost::asio::socket_base::shutdown_type::shutdown_send, ec);
|
||||
}
|
||||
|
||||
void shutdown_read()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
socket_.shutdown(boost::asio::socket_base::shutdown_type::shutdown_receive, ec);
|
||||
}
|
||||
|
||||
template <typename F>
|
||||
void start(F f)
|
||||
{
|
||||
@ -99,6 +117,24 @@ namespace crow
|
||||
raw_socket().close(ec);
|
||||
}
|
||||
|
||||
void shutdown_readwrite()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
raw_socket().shutdown(boost::asio::socket_base::shutdown_type::shutdown_both, ec);
|
||||
}
|
||||
|
||||
void shutdown_write()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
raw_socket().shutdown(boost::asio::socket_base::shutdown_type::shutdown_send, ec);
|
||||
}
|
||||
|
||||
void shutdown_read()
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
raw_socket().shutdown(boost::asio::socket_base::shutdown_type::shutdown_receive, ec);
|
||||
}
|
||||
|
||||
boost::asio::io_service& get_io_service()
|
||||
{
|
||||
return GET_IO_SERVICE(raw_socket());
|
||||
|
Loading…
Reference in New Issue
Block a user