Repository navigation
agent: fix three races that closing clients on a network change makes reachable - #1928
Closed
Narasimha-sc wants to merge 1 commit into
Closed
Narasimha-sc wants to merge 1 commit into
Narasimha-sc wants to merge 1 commit into
Conversation
This was referenced Oct 5, 2026
Closed
Closed
Narasimha-sc
force-pushed
the
nd/net-session-races
branch
from
October 5, 2026 10:46
6f39a94 to
c32661a
Compare
Narasimha-sc
force-pushed
the
nd/net-close-clients
branch
2 times, most recently
from
October 5, 2026 16:13
a1cf376 to
d4c68c9
Compare
Narasimha-sc
force-pushed
the
nd/net-session-races
branch
from
October 5, 2026 16:13
c32661a to
231d6f9
Compare
… reachable Closing the clients on a network change makes a client that is no longer the one in the session map a routine occurrence rather than a rare one, which makes these pre-existing races reachable in normal use. - setSubsPending removes the subscriptions of a transport session only when the session id matches. A client that is no longer the one in the map never set its session id, and when the session mode stopped matching the transport session its disconnection removed the subscriptions of the client that replaced it without making them pending, so they were neither subscribed nor scheduled and nothing corrected it until the app restarted. - smpClientDisconnected removes the sessions to the proxied relays only when no other client replaced this one, as those sessions are then the sessions of the client that replaced it. - updateClientService reads the stored service id in the transaction that writes it. The id read before the handshake can be stale, as the transaction of a client that is no longer current can commit after the one of the client that replaced it, and removeRcvServiceAssocs would then run against a service id that changed since, removing the associations of the current client.
Narasimha-sc
force-pushed
the
nd/net-close-clients
branch
from
October 5, 2026 21:20
d4c68c9 to
8e3f9a4
Compare
Narasimha-sc
force-pushed
the
nd/net-session-races
branch
from
October 5, 2026 21:20
231d6f9 to
2c4ea1f
Compare
This was referenced Oct 20, 2026
Closed
Closed
This was referenced Oct 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closing the clients on a network change makes a client that is no longer the one in the session map a routine occurrence rather than a rare one, which makes these pre-existing races reachable in normal use. None of them is introduced by this stack; all three would leave state wrong after a reconnect.
setSubsPendingremoves the subscriptions of a transport session only when the session id matches. A client that is no longer the one in the map never set its session id, and when the session mode stopped matching, its disconnection removed the subscriptions of the client that replaced it without making them pending - so they were neither subscribed nor scheduled, and nothing corrected it until the app restarted.smpClientDisconnectedremoves the sessions to the proxied relays only when no other client replaced this one, as those sessions are then the sessions of the client that replaced it.updateClientServicereads the stored service id in the transaction that writes it. The id read before the handshake can be stale, as the transaction of a client that is no longer current can commit after the one of the client that replaced it, andremoveRcvServiceAssocswould then run against a service id that changed since, removing the associations of the current client.This PR must land after the client-closing change, not before it:
setSubsPending's guard relies onnewProtocolClientsetting the session id only while its var is the one in the map.Stack
Reducing reconnection delay after a network change. Each PR is based on the previous one and can be merged on its own once the ones below it are in.
mastermaster