forked from quic-go/quic-go
refactor how sessions are deleted
Replacing sessions with different structs representing a closed session doesn't work if a session is using multiple connection IDs.
This commit is contained in:
@@ -65,12 +65,8 @@ func newPacketHandlerMap(
|
||||
|
||||
func (h *packetHandlerMap) Add(id protocol.ConnectionID, handler packetHandler) {
|
||||
h.mutex.Lock()
|
||||
h.addLocked(id, handler)
|
||||
h.mutex.Unlock()
|
||||
}
|
||||
|
||||
func (h *packetHandlerMap) addLocked(id protocol.ConnectionID, handler packetHandler) {
|
||||
h.handlers[string(id)] = handler
|
||||
h.mutex.Unlock()
|
||||
}
|
||||
|
||||
func (h *packetHandlerMap) Remove(id protocol.ConnectionID) {
|
||||
@@ -79,14 +75,6 @@ func (h *packetHandlerMap) Remove(id protocol.ConnectionID) {
|
||||
h.mutex.Unlock()
|
||||
}
|
||||
|
||||
func (h *packetHandlerMap) ReplaceWithClosed(id protocol.ConnectionID, handler packetHandler) {
|
||||
h.mutex.Lock()
|
||||
h.removeByConnectionIDAsString(string(id))
|
||||
h.addLocked(id, handler)
|
||||
h.mutex.Unlock()
|
||||
h.retireByConnectionIDAsString(string(id))
|
||||
}
|
||||
|
||||
func (h *packetHandlerMap) removeByConnectionIDAsString(id string) {
|
||||
delete(h.handlers, id)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user