Arm peer message writer wakeup before refilling its buffer - #1069
Open
softganz88 wants to merge 1 commit into
Open
Arm peer message writer wakeup before refilling its buffer#1069softganz88 wants to merge 1 commit into
softganz88 wants to merge 1 commit into
Conversation
softganz88
marked this pull request as ready for review
July 28, 2026 15:50
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.
What changed
writeCondbeforefillWriteBufferevaluates whether more peer messages are availableWhy
BroadcastConddoes not retain a broadcast when noSignaledchannel is armed. The peer message writer previously calledfillWriteBufferbefore armingwriteCond, while the refill observes peer state outsidecn.mu. A state transition could therefore broadcast during refill, leave the write buffer empty, and be lost before the writer began waiting. With no later transition, the writer remained asleep.Arming the condition first retains a broadcast from that refill window without changing the existing closed-channel or keepalive selection.
Validation
go test -run '^TestPeerConnMsgWriterArmsWakeupBeforeRefill$' -count=100 .cargo buildin the pinnedstorage/possum/libsubmodule, thengo test ./...gofmtandgit diff --checkThe regression uses channel synchronization and contains no timing sleep for the target interleaving. It fails on commit
8c67afb7185d42ea94dcced246596d79d35feb64and passes after this change.