Skip to content

Commit 0ed9c74

Browse files
committed
Fix race in writeFrame
1 parent 4357cbf commit 0ed9c74

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

websocket.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,6 @@ func (c *Conn) writeFrame(ctx context.Context, fin bool, opcode opcode, p []byte
632632
}
633633
}
634634

635-
headerBytes := writeHeader(c.writeHeaderBuf, h)
636-
637635
err := c.acquireLock(ctx, c.writeFrameLock)
638636
if err != nil {
639637
return 0, err
@@ -664,6 +662,7 @@ func (c *Conn) writeFrame(ctx context.Context, fin bool, opcode opcode, p []byte
664662
return err
665663
}
666664

665+
headerBytes := writeHeader(c.writeHeaderBuf, h)
667666
_, err = c.bw.Write(headerBytes)
668667
if err != nil {
669668
return 0, writeErr(err)

0 commit comments

Comments
 (0)