Skip to content

Commit 7784bef

Browse files
committed
JsonRpcConnection: use AsioTlsStream::GracefulDisconnect()
This new helper functions allows deduplicating the timeout handling for `async_shutdown()`.
1 parent 3e29c8e commit 7784bef

File tree

1 file changed

+1
-27
lines changed

1 file changed

+1
-27
lines changed

lib/remote/jsonrpcconnection.cpp

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -225,36 +225,10 @@ void JsonRpcConnection::Disconnect()
225225

226226
m_WriterDone.Wait(yc);
227227

228-
/*
229-
* Do not swallow exceptions in a coroutine.
230-
* https://github.com/Icinga/icinga2/issues/7351
231-
* We must not catch `detail::forced_unwind exception` as
232-
* this is used for unwinding the stack.
233-
*
234-
* Just use the error_code dummy here.
235-
*/
236-
boost::system::error_code ec;
237-
238228
m_CheckLivenessTimer.cancel();
239229
m_HeartbeatTimer.cancel();
240230

241-
m_Stream->lowest_layer().cancel(ec);
242-
243-
Timeout::Ptr shutdownTimeout (new Timeout(
244-
m_IoStrand.context(),
245-
m_IoStrand,
246-
boost::posix_time::seconds(10),
247-
[this, keepAlive](asio::yield_context yc) {
248-
boost::system::error_code ec;
249-
m_Stream->lowest_layer().cancel(ec);
250-
}
251-
));
252-
253-
m_Stream->next_layer().async_shutdown(yc[ec]);
254-
255-
shutdownTimeout->Cancel();
256-
257-
m_Stream->lowest_layer().shutdown(m_Stream->lowest_layer().shutdown_both, ec);
231+
m_Stream->GracefulDisconnect(m_IoStrand, yc);
258232
});
259233
}
260234
}

0 commit comments

Comments
 (0)