fix: make SCTPWrite non-blocking to avoid stalling on a full send queue - #90
Open
gomaja wants to merge 1 commit into
Open
fix: make SCTPWrite non-blocking to avoid stalling on a full send queue#90gomaja wants to merge 1 commit into
gomaja wants to merge 1 commit into
Conversation
SCTPWrite called sendmsg with no flags, so it blocked whenever the send queue was full. A peer that stops reading, or goes away without tearing the association down, therefore parked the writing goroutine indefinitely and left the connection in CLOSE_WAIT with no way for the caller to recover. Pass MSG_DONTWAIT so the caller gets EAGAIN and can decide what to do. This changes SCTPWrite's contract, so it is worth stating plainly. Callers that previously relied on the write blocking until there was room must now handle EAGAIN and retry; a plain write loop that ignores the error will drop messages. The tests measure this rather than assert it away: with a peer that has stopped reading the writer reports EAGAIN instead of hanging, and even against an actively reading peer roughly one write in twenty returns EAGAIN once the writer outruns the reader. A retry loop delivers all of them.
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.
Split out of #87, where it was buried in an unrelated close-logic change. It alters
SCTPWrite's contract for every caller, so it is better reviewed on its own.SCTPWritecalledsendmsgwith no flags, so it blocked whenever the send queue was full. A peer that stops reading, or goes away without tearing the association down, parked the writing goroutine indefinitely and left the connection inCLOSE_WAITwith no way for the caller to recover. PassingMSG_DONTWAITreturnsEAGAINinstead, so the caller decides what to do.Compatibility
This is a behaviour change worth stating plainly: callers that relied on the write blocking until there was room must now handle
EAGAINand retry. A plain write loop that ignores the error will drop messages.EAGAINis also not limited to a peer that has stopped reading — a writer that outruns an actively reading peer sees it too. The tests measure this rather than assert it away:EAGAINinstead of hangingEAGAINonce the writer gets aheadThe middle case is the one existing callers will notice, so it is a test rather than a comment.