good morning!!!!

Skip to content
Snippets Groups Projects
Unverified Commit 897a5732 authored by Anmol Sethi's avatar Anmol Sethi Committed by GitHub
Browse files

write.go: Fix deadlock in writeFrame (#253)

Closes #248

Luckily, due to the 5s timeout on the close handshake, this would have
had very minimal effects on anyone in production.
parent 493ebbe9
No related branches found
No related tags found
No related merge requests found
......@@ -257,7 +257,6 @@ func (c *Conn) writeFrame(ctx context.Context, fin bool, flate bool, opcode opco
if err != nil {
return 0, err
}
defer c.writeFrameMu.unlock()
// If the state says a close has already been written, we wait until
// the connection is closed and return that error.
......@@ -268,6 +267,7 @@ func (c *Conn) writeFrame(ctx context.Context, fin bool, flate bool, opcode opco
wroteClose := c.wroteClose
c.closeMu.Unlock()
if wroteClose && opcode != opClose {
c.writeFrameMu.unlock()
select {
case <-ctx.Done():
return 0, ctx.Err()
......@@ -275,6 +275,7 @@ func (c *Conn) writeFrame(ctx context.Context, fin bool, flate bool, opcode opco
return 0, c.closeErr
}
}
defer c.writeFrameMu.unlock()
select {
case <-c.closed:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment