Skip to content

Commit f88d52e

Browse files
committed
1 parent 3758d3a commit f88d52e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

write.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,6 @@ func (c *Conn) writeFrame(ctx context.Context, fin bool, flate bool, opcode opco
248248
if err != nil {
249249
return 0, err
250250
}
251-
defer c.writeFrameMu.unlock()
252251

253252
// If the state says a close has already been written, we wait until
254253
// the connection is closed and return that error.
@@ -259,13 +258,15 @@ func (c *Conn) writeFrame(ctx context.Context, fin bool, flate bool, opcode opco
259258
wroteClose := c.wroteClose
260259
c.closeMu.Unlock()
261260
if wroteClose && opcode != opClose {
261+
c.writeFrameMu.unlock()
262262
select {
263263
case <-ctx.Done():
264264
return 0, ctx.Err()
265265
case <-c.closed:
266266
return 0, c.closeErr
267267
}
268268
}
269+
defer c.writeFrameMu.unlock()
269270

270271
select {
271272
case <-c.closed:

0 commit comments

Comments
 (0)