Commit graph

5 commits

Author SHA1 Message Date
Johannes Schmidt
1b568ac50e Fix PerfdataWriterConnection segfaults on non-X86 architectures
The issue is that std::promise internally also used thread local
storage, in a call to `std::call_once` in `std::promise::set_value()`.
The theory is that since all paths in `Send()` run this `std::call_once`
routine and from then on, then Coroutine function looks like a normal
function, the compiler inlined `set_value()` and moved the common parts
of it to a common location for all paths before the suspension point in
WriteMessage(yc).

When finally the coroutine is resumes, it is likely that that happens
under a different thread, which still has `__once_callable` in
`std::call_once` set as `nullptr`, leading to the segmentation fault.

The fix is to not use std::promise across coroutine suspension points
and instead reimplement the functionality we required from it in a small
helper class `SyncResult` that does not require any thread local storag.
2026-04-29 13:29:36 +02:00
Johannes Schmidt
24034e49b2 Fix ineffective cancel() when stuck in perfdata writer handshake
On slow systems like our ARM64 Container Image build async_handshake()
can not be cancelled in one go but needs two cancels with a chance
to run the completion handler in between. The exact reason is unknown,
and this has been found through trial and error. The alternative would
have been a socket close() in case the connection is not fully established.
2026-04-29 12:47:17 +02:00
Johannes Schmidt
100206ff06 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.
2026-04-29 12:47:17 +02:00
Johannes Schmidt
f5be692d33 Correctly create AsioTlsStream with host argument
This was omitted by accident from the original PR, despite
being done in the original perfdata writer connection code.

Without setting this parameter, host name verification will be
disabled, which poses a security risk.
2026-04-17 10:08:20 +02:00
Johannes Schmidt
2e2576c7c5 Add PerfdataWriterConnection class 2026-03-06 10:55:05 +01:00