Repository navigation
srxsync: lock candidate config at connect() in rustez, matching PyEZ - #9
Merged
Merged
Conversation
rustez deferred the candidate lock to the first load(), while PyEZTransport locks in connect() and holds it through close(). That left a window on the push path (connect -> load) where another session could mutate the candidate config unlocked, and made rustez's read-only `check` path never lock at all while PyEZ's did. Move the rustez lock into connect() so both backends take and hold the lock at the same point in the session lifecycle. Adds a test per backend covering the lock timing. Closes #8 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
5 tasks done
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.
Summary
PyEZTransport takes the exclusive candidate lock in
connect()and holds it untilclose(). RustezTransport deferred locking to the firstload()call, which left a window on the push path (connect()→load()) where another session could mutate the candidate config while ours sat unlocked, and meant a read-onlycheck(connect()+fetch(), noload()) never locked at all on rustez while it always locked on PyEZ (#7 documented this without fixing it).This moves the rustez lock acquisition into
connect()so both backends take and hold the lock at the same point in the session lifecycle.load()no longer lazily creates/locks theConfigobject — it uses the one set up inconnect().Changes
srxsync/transport/rustez.py:connect()now creates theConfigand callslock()right afterDevice.open(), settingself._locked = True.load()no longer lazily locks.README.md: updated the "Locking differs between backends" note to describe the now-unified behavior.tests/unit/test_transport_pyez.py::test_connect_locks_before_any_read— asserts PyEZ's existing lock-in-connect()ordering (open, then lock) as a baseline/regression guard.tests/unit/test_transport_rustez.py::test_connect_locks_immediately_like_pyez— asserts rustez now locks inconnect()(fails against the old code, whereconnect()never touchedConfig).tests/unit/test_transport_rustez.py::test_load_does_not_relock— assertsload()reuses the existing lock rather than callinglock()again.Verification
No new dependencies. No live device access used — verified against fixtures/mocks per existing test patterns in
tests/unit/test_transport_{pyez,rustez}.py.Closes #8
🤖 Generated with Claude Code