Skip to content

Commit

Permalink
websocket: fix send queue buffer release
Browse files Browse the repository at this point in the history
  • Loading branch information
lesismal committed Sep 2, 2024
1 parent 428f1a7 commit d2b0199
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions nbhttp/websocket/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -796,13 +796,14 @@ func (c *Conn) writeFrame(messageType MessageType, sendOpcode, fin bool, data []
i := 0
for {
_, err := c.Conn.Write(buf)
c.Engine.BodyAllocator.Free(buf)
if err != nil {
c.CloseWithError(err)
return
}

c.Engine.BodyAllocator.Free(buf)
c.sendQueue[i] = nil
i++

c.mux.Lock()
if c.closed {
c.mux.Unlock()
Expand All @@ -815,7 +816,6 @@ func (c *Conn) writeFrame(messageType MessageType, sendOpcode, fin bool, data []
}

buf = c.sendQueue[i]
c.sendQueue[i] = nil

c.mux.Unlock()

Expand Down

0 comments on commit d2b0199

Please sign in to comment.