Skip to content

Commit

Permalink
Add timeout for boost::asio::ssl::stream#async_shutdown()
Browse files Browse the repository at this point in the history
  • Loading branch information
Al2Klimov committed Jun 17, 2020
1 parent 6532e9e commit f1278d1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/remote/jsonrpcconnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,20 @@ void JsonRpcConnection::Disconnect()

m_Stream->lowest_layer().cancel(ec);

Timeout::Ptr shutdownTimeout (new Timeout(
m_IoStrand.context(),
m_IoStrand,
boost::posix_time::seconds(10),
[this, keepAlive](asio::yield_context yc) {
boost::system::error_code ec;
m_Stream->lowest_layer().cancel(ec);
}
));

m_Stream->next_layer().async_shutdown(yc[ec]);

shutdownTimeout->Cancel();

m_Stream->lowest_layer().shutdown(m_Stream->lowest_layer().shutdown_both, ec);
}
});
Expand Down

0 comments on commit f1278d1

Please sign in to comment.