mirror of
https://github.com/refraction-networking/uquic.git
synced 2025-04-05 05:07:36 +03:00
release packet buffers when deleting a 0-RTT queue
This commit is contained in:
parent
ba095dd3ff
commit
9b71878d53
2 changed files with 32 additions and 6 deletions
|
@ -30,11 +30,7 @@ func (h *zeroRTTQueue) Enqueue(connID protocol.ConnectionID, p *receivedPacket)
|
|||
if len(h.queue) >= protocol.Max0RTTQueues {
|
||||
return
|
||||
}
|
||||
h.queue[cid] = &zeroRTTQueueEntry{timer: time.AfterFunc(protocol.Max0RTTQueueingDuration, func() {
|
||||
h.mutex.Lock()
|
||||
delete(h.queue, cid)
|
||||
h.mutex.Unlock()
|
||||
})}
|
||||
h.queue[cid] = &zeroRTTQueueEntry{timer: time.AfterFunc(protocol.Max0RTTQueueingDuration, func() { h.deleteQueue(connID) })}
|
||||
}
|
||||
entry := h.queue[cid]
|
||||
if len(entry.packets) >= protocol.Max0RTTQueueLen {
|
||||
|
@ -59,3 +55,17 @@ func (h *zeroRTTQueue) Dequeue(connID protocol.ConnectionID) *receivedPacket {
|
|||
}
|
||||
return p
|
||||
}
|
||||
|
||||
func (h *zeroRTTQueue) deleteQueue(connID protocol.ConnectionID) {
|
||||
h.mutex.Lock()
|
||||
defer h.mutex.Unlock()
|
||||
|
||||
entry, ok := h.queue[string(connID)]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
for _, p := range entry.packets {
|
||||
p.buffer.Release()
|
||||
}
|
||||
delete(h.queue, string(connID))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue