Repository navigation
SBP-2: LoginSession as a std::variant state machine - #227
Merged
Merged
Conversation
Owner
|
Could you check it please? |
Contributor
Author
Oops, you're right! Thank you |
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.
Follow-up to the #216 review.
LoginSessionis now astd::variantstate machine, so the login ID lives only in the states that hold a login and theLoginID() == 0sentinel is gone. The H4D assigns login_ID 0 (all 20 LUN reset ORBs in the #213 capture), so before this it got a Login instead of a Reconnect after every reset.This PR keeps the wire behaviour the same, apart from the changes listed below. The places where we differed from Apple/Linux are fixed in a small PR on top (#228).
Your five points:
LoginFsm::St::*inLoginStateMachine.hpp:LoggedIn{login, route},Reconnecting{login, route},LoggingOut{login, route}, andSuspendedsplit intoSuspendedHeld{login}(reconnect) andSuspendedNoLogin(log in).HeldLoginis the login response: login_ID, command block agent, reconnect_hold.RefreshTargetsnow just callsResume(), and the state decides.Transition(state, event, now) → {next, effects}is pure;LoginSessionfeeds it events and carries out the effects (writes, timers, bind, callbacks) in a fixed order. Stale write completions (older generation or another op) are dropped there instead of in scattered checks. The table, with Apple/Linux citations per row, is indocumentation/sbp2-login-fsm.md.StartLogin/ReleaseSessionfrom its own queue (noQUEUENAME, no hop). Hopping it withDispatchSynclooked like the FW-60 teardown trap, soLoginSessionserializes itself instead: a small locked queue of work, run one piece at a time by whichever thread finds it idle. The lock covers only the queue, so callbacks still take the registry's lock without an AB-BA againstOnBusReset. Observers readSnapshot(): state, generation and login ID in one atomic word.LoginStatestays the reported enum. The registry, the bridge and the user client are unchanged apart from reading the snapshot.LoginStateMachineTests: one test per transition (45), including a held login with ID 0 reconnecting. Integration:SessionRegistryTests.LoginIdZeroReconnectsAfterRediscovery, plus executor tests (a callback calling back in, a request from another thread queued behind running work). The cross-thread test fails if the queue is removed. The existingLoginSessionTestspass unchanged apart fromReconnect()→Resume().Behaviour changes (also in the doc):
LoginCompleteParamsno longer carries the status block (nothing read it).Not covered: the user-client path still drives
CommandExecutor/FetchAgentfrom its own queue, as before.Not tested on hardware yet. Host suite: 3877 passing.