fix(qwp-ws): enforce per-call contract for flushAndGetSequence() and override drain() (#7142)#48
Open
adi1719 wants to merge 2 commits into
Open
fix(qwp-ws): enforce per-call contract for flushAndGetSequence() and override drain() (#7142)#48adi1719 wants to merge 2 commits into
adi1719 wants to merge 2 commits into
Conversation
flushAndGetSequence() returned the global published-FSN watermark instead of -1 when no data was published by the call. This caused the default Sender.drain() to short-circuit immediately after an empty flush, even with prior unacked frames still in flight. - Snapshot publishedFsn before/after flush; return -1 when unchanged - Override drain() with watermark semantics so it always waits for all published frames - Add deterministic CloseDrainTest with DelayingAckHandler - Simplify dead afterFsn != -1L guard Fixes #7142
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.
QwpWebSocketSender.flushAndGetSequence()documented a per-call contract(return -1 when nothing published by this call) but returned the global
published-FSN watermark instead. An empty flush after a previous publish
would return the previous FSN rather than -1.
This change enforces the formal per-call contract by comparing the
published FSN before and after the flush work — returning the new FSN
only when this call actually advanced it, and -1 otherwise.
Because the default
Sender.drain()implementation relies onflushAndGetSequence()to obtain its wait target, an empty-flushreturning -1 would cause
drain()to short-circuit immediately evenwith prior unacknowledged frames in flight. To preserve correct drain
semantics,
QwpWebSocketSendernow overridesdrain()to use thecurrent published-FSN watermark as the wait target (matching the
existing
drainOnClose()approach).Changes:
QwpWebSocketSender.flushAndGetSequence(): snapshot publishedFsnbefore/after flush, return afterFsn only when it advanced
QwpWebSocketSender.drain(): new override using watermark semanticsSender.drain(): updated Javadoc noting implementations may overridewith watermark semantics
testFlushAndGetSequenceReturnsNegativeOneWhenNothingPublishedand
testDrainWaitsForPriorUnackedFramesCloses #7142