Commit graph

6 commits

Author SHA1 Message Date
Johannes Schmidt
792c70393a 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 storage.
2026-05-26 12:18:54 +02:00
Johannes Schmidt
3cc5ee2122 Ignore errors for close() and TCP-shutdown()
This makes the TCP-path also ignore all errors/exceptions, same as the
TLS-path's `GracefulDisconnect()`.
2026-05-26 12:12:17 +02:00
Johannes Schmidt
db7a056cee Fix ineffective cancel() when stuck in perfdata writer handshake 2026-05-19 09:33:23 +02:00
Johannes Schmidt
55eb326a56 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-05-19 09:33:23 +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