replace all connection IDs at the same time when connection is closed

This commit is contained in:
Marten Seemann 2022-08-21 14:09:49 +03:00
parent 635dc90475
commit c3ab9c4ea9
7 changed files with 34 additions and 25 deletions

View file

@ -20,7 +20,7 @@ type connIDGenerator struct {
getStatelessResetToken func(protocol.ConnectionID) protocol.StatelessResetToken
removeConnectionID func(protocol.ConnectionID)
retireConnectionID func(protocol.ConnectionID)
replaceWithClosed func(protocol.ConnectionID, packetHandler)
replaceWithClosed func([]protocol.ConnectionID, packetHandler)
queueControlFrame func(wire.Frame)
version protocol.VersionNumber
@ -33,7 +33,7 @@ func newConnIDGenerator(
getStatelessResetToken func(protocol.ConnectionID) protocol.StatelessResetToken,
removeConnectionID func(protocol.ConnectionID),
retireConnectionID func(protocol.ConnectionID),
replaceWithClosed func(protocol.ConnectionID, packetHandler),
replaceWithClosed func([]protocol.ConnectionID, packetHandler),
queueControlFrame func(wire.Frame),
version protocol.VersionNumber,
) *connIDGenerator {
@ -131,10 +131,12 @@ func (m *connIDGenerator) RemoveAll() {
}
func (m *connIDGenerator) ReplaceWithClosed(handler packetHandler) {
connIDs := make([]protocol.ConnectionID, 0, len(m.activeSrcConnIDs)+1)
if m.initialClientDestConnID != nil {
m.replaceWithClosed(m.initialClientDestConnID, handler)
connIDs = append(connIDs, m.initialClientDestConnID)
}
for _, connID := range m.activeSrcConnIDs {
m.replaceWithClosed(connID, handler)
connIDs = append(connIDs, connID)
}
m.replaceWithClosed(connIDs, handler)
}