ackhandler: remove the packet list element from the correct list

This commit is contained in:
Marten Seemann
2022-12-30 18:35:05 +13:00
parent d2512193da
commit dd30a02627
2 changed files with 6 additions and 6 deletions

View File

@@ -108,8 +108,7 @@ func (h *sentPacketHistory) Remove(p protocol.PacketNumber) error {
if !ok {
return fmt.Errorf("packet %d not found in sent packet history", p)
}
h.outstandingPacketList.Remove(el)
h.etcPacketList.Remove(el)
el.List().Remove(el)
delete(h.packetMap, p)
return nil
}
@@ -139,10 +138,7 @@ func (h *sentPacketHistory) DeclareLost(p *Packet) *Packet {
if !ok {
return nil
}
// try to remove it from both lists, as we don't know which one it currently belongs to.
// Remove is a no-op for elements that are not in the list.
h.outstandingPacketList.Remove(el)
h.etcPacketList.Remove(el)
el.List().Remove(el)
p.declaredLost = true
// move it to the correct position in the etc list (based on the packet number)
for el = h.etcPacketList.Back(); el != nil; el = el.Prev() {

View File

@@ -43,6 +43,10 @@ func (e *Element[T]) Prev() *Element[T] {
return nil
}
func (e *Element[T]) List() *List[T] {
return e.list
}
// List represents a doubly linked list.
// The zero value for List is an empty list ready to use.
type List[T any] struct {