Repository navigation
fix: answer in-flight pings after sending close - #609
Open
doctorcorral wants to merge 1 commit into
Open
doctorcorral wants to merge 1 commit into
doctorcorral wants to merge 1 commit into
Conversation
writeFrame refused every opcode once closeSentErr was set, so an in-flight ping during Close aborted waitCloseHandshake before the peer's close frame was read. RFC 6455 section 5.5.2 requires a pong until a close frame has been received, so opPong is now allowed after close is sent. Fixes coder#585
This branch has not been deployed
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.
Fixes #585.
writeFramecurrently rejects every opcode oncecloseSentErris set. If a Ping that was already on the wire arrives duringClose,handleControltries to write a Pong,writeFramereturnsnet.ErrClosed, andwaitCloseHandshakeaborts before the peer's Close frame is read.Closethen swallowsnet.ErrClosedand returnsnil, so the caller sees success even though the handshake did not finish and no Pong was sent.RFC 6455 §5.5.2 requires a Pong unless a Close frame has already been received. §5.5.1 only forbids further data frames after sending Close. §7.1.2 expects the endpoint to finish sending and receiving Close before tearing down TCP.
This change allows
opPongthroughwriteFrameafter Close has been sent.closeReceivedErrdoes not need a matching check:prepareReadalready stops the read loop once a Close has been received, andc.closedalready refuses writes after the connection is torn down.A
net.Piperegression test covers the case: after this side sends Close, the peer writes a Ping and then Close; we answer with a matching Pong, read the peer Close, andClosereturnsnil.The same approach was previously opened as #595 and closed unmerged, without review.
This does not change WASM (
ws_js.go), where the browser owns ping/pong and framing.