mirror of
https://github.com/boostorg/beast.git
synced 2025-07-30 21:07:26 +02:00
@ -215,14 +215,13 @@ do_session(
|
|||||||
tcp_stream stream,
|
tcp_stream stream,
|
||||||
std::shared_ptr<std::string const> doc_root)
|
std::shared_ptr<std::string const> doc_root)
|
||||||
{
|
{
|
||||||
beast::error_code ec;
|
|
||||||
|
|
||||||
// This buffer is required to persist across reads
|
// This buffer is required to persist across reads
|
||||||
beast::flat_buffer buffer;
|
beast::flat_buffer buffer;
|
||||||
|
|
||||||
// This lambda is used to send messages
|
// This lambda is used to send messages
|
||||||
for(;;)
|
|
||||||
try
|
try
|
||||||
|
{
|
||||||
|
for(;;)
|
||||||
{
|
{
|
||||||
// Set the timeout.
|
// Set the timeout.
|
||||||
stream.expires_after(std::chrono::seconds(30));
|
stream.expires_after(std::chrono::seconds(30));
|
||||||
@ -248,6 +247,7 @@ do_session(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (boost::system::system_error & se)
|
catch (boost::system::system_error & se)
|
||||||
{
|
{
|
||||||
if (se.code() != http::error::end_of_stream )
|
if (se.code() != http::error::end_of_stream )
|
||||||
@ -255,9 +255,12 @@ do_session(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Send a TCP shutdown
|
// Send a TCP shutdown
|
||||||
|
beast::error_code ec;
|
||||||
stream.socket().shutdown(tcp::socket::shutdown_send, ec);
|
stream.socket().shutdown(tcp::socket::shutdown_send, ec);
|
||||||
|
|
||||||
// At this point the connection is closed gracefully
|
// At this point the connection is closed gracefully
|
||||||
|
// we ignore the error because the client might have
|
||||||
|
// dropped the connection already.
|
||||||
}
|
}
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@ -287,6 +290,7 @@ do_listen(
|
|||||||
do_session(tcp_stream(co_await acceptor.async_accept()), doc_root),
|
do_session(tcp_stream(co_await acceptor.async_accept()), doc_root),
|
||||||
[](std::exception_ptr e)
|
[](std::exception_ptr e)
|
||||||
{
|
{
|
||||||
|
if (e)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::rethrow_exception(e);
|
std::rethrow_exception(e);
|
||||||
|
Reference in New Issue
Block a user