Skip to content

Commit

Permalink
conn.go: Return unacknowledged packets to packet pool on close.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sandertv committed Jun 22, 2024
1 parent ccb02cc commit 551b294
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,15 @@ func (conn *Conn) closeImmediately() {
_, _ = conn.Write([]byte{message.IDDisconnectNotification})
conn.handler.close(conn)
close(conn.closed)

conn.mu.Lock()
defer conn.mu.Unlock()
// Make sure to return all unacknowledged packets to the packet pool.
for _, record := range conn.retransmission.unacknowledged {
record.pk.content = record.pk.content[:0]
packetPool.Put(record.pk)
}
clear(conn.retransmission.unacknowledged)
})
}

Expand Down

0 comments on commit 551b294

Please sign in to comment.