fix(agent): compare-and-clear session teardown on connection generation #99
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/VS-81-connection-generation-compare-and-clear"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Overlapping agent connections for one node_id let a stale connection's teardown clobber the live one.
handle_sessionkeyed connectivity, the outbound sender, and disconnect notify bynode_idalone, and the post-loop cleanup cleared them unconditionally. When a host reconnected while the server still held a half-open prior socket, connection B overwrote A's sender viaset_sender; when A's dead socket was finally detected, A's cleanup cleared the bit and sender that now belonged to B, so the device showed offline and outbound commands silently dropped while the agent was live on B.Give each connection a monotonic generation owned by
AgentRegistry.set_senderstamps a fresh generation (from a globalAtomicU64) and returns it; teardown callsclear_sender_if_current(node_id, generation), which clears the sender and self-update slot only when the stored generation still matches. A stale, superseded connection's generation no longer matches, so its teardown is a no-op.agent.rsgates the connectivity-bit clear and the agentdisconnect/power-off logging on that result, so a stale teardown never marks a live device offline.VS-80's read-idle deadline turns half-open sockets over faster and makes this overlap more likely, so this lands alongside it.
#VS-81