Repository navigation
Conversation
writeFrame refused every opcode once a close frame was sent, so a ping the peer sent before it saw our close got no pong. The failed pong write also aborted waitCloseHandshake before the peer's close frame was read, while Close still returned nil. RFC 6455 section 5.5.2 requires a pong until a close frame has been received, so allow pongs 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.
Once a close frame has been sent,
writeFramereturnsnet.ErrClosedfor every opcode. If the peer sent a ping before it saw our close,waitCloseHandshakereads it,handleControltries to write the pong, and that write fails. The error endswaitCloseHandshakebefore the peer's close frame is read, andClosestill returns nil because the deferred check mapsnet.ErrClosedto nil. RFC 6455 section 5.5.2 says an endpoint must answer a ping unless it has already received a close frame, so the pong should still go out.This allows
opPongthrough the close-sent check inwriteFrameand keeps refusing everything else. It's the change suggested in the issue.Test:
TestCloseAnswersPingBeforePeerCloseusesnet.Pipeand a raw peer that reads our close frame, sends a ping, expects a pong with the same payload, then sends its close frame. It fails onmaster(no pong) and passes with this change.go test -race ./...passes andgofmtis clean. I didn't run the autobahn suite.I used AI assistance to write this; I ran the tests above myself.