mirror of
https://github.com/torlando-tech/pyxis.git
synced 2026-08-07 03:09:49 +00:00
fix(tcp): publish CONNECTED before _reconnected so the announce isn't dropped (greptile)
Storing _reconnected before _conn_state=CONNECTED left a seq-cst window where the main loop could observe _reconnected==true while still CONNECTING. check_reconnected() would then clear the flag and announce on an offline interface (loop() returns early), so no announce fired once actually connected. Store CONNECTED first; seq-cst then guarantees _reconnected is only ever observed true on an online interface. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UWZuYkHBRqNb6BZHV8sTG5
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
7be3138fc5
commit
afd374ff3f
@@ -293,8 +293,13 @@ void TCPClientInterface::task_loop() {
|
||||
// _online is owned by the main loop (it sets it on
|
||||
// observing CONNECTED); writing it here would race with
|
||||
// loop()'s `_online = false` during the CONNECTING window.
|
||||
_reconnected.store(true); // main loop announces
|
||||
// Publish CONNECTED BEFORE _reconnected: seq-cst then
|
||||
// guarantees that whenever the main loop observes
|
||||
// _reconnected==true the interface is already CONNECTED,
|
||||
// so check_reconnected() can't fire the announce on an
|
||||
// offline interface (which would drop it).
|
||||
_conn_state.store(CONNECTED); // hand _client to main loop
|
||||
_reconnected.store(true); // main loop announces
|
||||
} else {
|
||||
_conn_state.store(DISCONNECTED);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user