From b24f438daa75e99bc3fb743628048ad18d538200 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Thu, 27 Feb 2020 13:24:57 +0100 Subject: [PATCH] Add timeout for boost::asio::ssl::stream#async_shutdown() refs #7203 --- lib/remote/jsonrpcconnection.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/remote/jsonrpcconnection.cpp b/lib/remote/jsonrpcconnection.cpp index 479fdea05a3..7fd8775a70d 100644 --- a/lib/remote/jsonrpcconnection.cpp +++ b/lib/remote/jsonrpcconnection.cpp @@ -235,8 +235,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); } });