fix: resolve writelock contention in DoraChannel receive_p2p (#202)#285
Merged
lijingrs merged 2 commits intomofa-org:mainfrom Feb 24, 2026
Merged
Conversation
lijingrs
approved these changes
Feb 23, 2026
10dceb3 to
a8801c4
Compare
lijingrs
approved these changes
Feb 24, 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.
Summary
Fixes a deadlock in
DoraChannel::receive_p2pwhere a write lock on thereceiversmawas held across an asyncrx.recv().await, blocking all concurrent callers for up to 30 seconds.Fixes: #202 and continues #212
Changes:
receiversmap value type frommpsc::ReceivertoArc<Mutex<mpsc::Receiver>>receive_p2pto acquire a brief read lock, clone the Arc, drop the map lock,then await on the per-agent mutex only
try_receive_p2pwith the same pattern using.lock.await()register_agentto wrap the new receiver inArc::new(Mutex::new(rx))test_p2p_receive_deadlockto reproduce and verify the fixTesting
The added test
test_p2p_receive_deadlockspawns a blocking receive and concurrently callsregister_agent, asserting it completes in under 400 ms. It failed before the fix and passes after.