Skip to content

Commit 69f55f3

Browse files
bhallionOhbibinhooyr
authored andcommitted
read.go: Avoid handling ping after close frame has been sent
Closes coder#298
1 parent c537145 commit 69f55f3

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

read.go

+7
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,13 @@ func (c *Conn) handleControl(ctx context.Context, h header) (err error) {
286286

287287
switch h.opcode {
288288
case opPing:
289+
c.closeMu.Lock()
290+
wroteClose := c.wroteClose
291+
c.closeMu.Unlock()
292+
if wroteClose {
293+
// Cannot respond to ping with a pong because we already sent a close frame.
294+
return nil
295+
}
289296
return c.writeControl(ctx, opPong, b)
290297
case opPong:
291298
c.activePingsMu.Lock()

0 commit comments

Comments
 (0)