File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -256,7 +256,22 @@ void JsonRpcConnection::Disconnect()
256256 IoEngine::SpawnCoroutine (m_IoStrand, [this , keepAlive](asio::yield_context yc) {
257257 m_OutgoingMessagesQueued.Set ();
258258
259- m_WriterDone.Wait (yc);
259+ {
260+ Timeout writerTimeout (
261+ m_IoStrand,
262+ boost::posix_time::seconds (5 ),
263+ [this ]() {
264+ // The writer coroutine could not finish soon enough to unblock the waiter down blow,
265+ // so we have to do this on our own, and the coroutine will be terminated forcibly when
266+ // the ops on the underlying socket are cancelled.
267+ boost::system::error_code ec;
268+ m_Stream->lowest_layer ().cancel (ec);
269+ }
270+ );
271+
272+ m_WriterDone.Wait (yc);
273+ // We don't need to explicitly cancel the timer here; its destructor will handle it for us.
274+ }
260275
261276 m_CheckLivenessTimer.cancel ();
262277 m_HeartbeatTimer.cancel ();
You can’t perform that action at this time.
0 commit comments