fix memory leak on connection ID rotation when closing connection (#4852)

* fix memory leak on connection ID rotation during CONNECTION_CLOSE

In rare instances, the connection ID manager might switch to a new
connection ID when sending the packet containing the CONNECTION_CLOSE
frame. The connection ID manager removes the active stateless reset
token from the packet handler map when it is closed, so we need to make
sure that this happens last, otherwise the packet handler will keep a
pointer to the closed connection indefinitely.

* defer

* panic on use of connIDManager after Close
This commit is contained in:
Marten Seemann
2025-01-22 03:35:16 -08:00
committed by GitHub
parent 302308335c
commit d41f9749d3
3 changed files with 25 additions and 1 deletions

View File

@@ -242,4 +242,7 @@ func TestConnIDManagerClose(t *testing.T) {
require.Empty(t, removedTokens)
m.Close()
require.Equal(t, []protocol.StatelessResetToken{{16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1}}, removedTokens)
require.Panics(t, func() { m.Get() })
require.Panics(t, func() { m.SetStatelessResetToken(protocol.StatelessResetToken{}) })
}