mirror of
https://github.com/Icinga/icinga2.git
synced 2026-05-28 04:12:13 -04:00
Fix a race-condition when perfdata writer is stuck in handshake
The issue occurs when ::Connect in `EnsureConnected()` returns after `Disconnect()` has already set `m_Stopped` to true. By adding a check and throwing an exception before entering `async_handshake()` the behavior should now always be consistent.
This commit is contained in:
parent
339434c8b4
commit
55eb326a56
1 changed files with 5 additions and 1 deletions
|
|
@ -62,7 +62,7 @@ bool PerfdataWriterConnection::IsStopped() const
|
|||
|
||||
void PerfdataWriterConnection::Disconnect()
|
||||
{
|
||||
if (m_Stopped.exchange(true, std::memory_order_relaxed)) {
|
||||
if (m_Stopped.exchange(true)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -133,6 +133,10 @@ void PerfdataWriterConnection::EnsureConnected(const boost::asio::yield_context&
|
|||
::Connect(stream->lowest_layer(), m_Host, m_Port, yc);
|
||||
|
||||
if constexpr (std::is_same_v<std::decay_t<decltype(stream)>, Shared<AsioTlsStream>::Ptr>) {
|
||||
if (m_Stopped) {
|
||||
BOOST_THROW_EXCEPTION(Stopped{});
|
||||
}
|
||||
|
||||
using type = boost::asio::ssl::stream_base::handshake_type;
|
||||
|
||||
stream->next_layer().async_handshake(type::client, yc);
|
||||
|
|
|
|||
Loading…
Reference in a new issue