don't use closures for passing OnLost and OnAcked STREAM frame callbacks (#3833)

This commit is contained in:
Marten Seemann 2023-06-02 14:14:04 +03:00 committed by GitHub
parent ad79149738
commit f8d24ef1e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 327 additions and 250 deletions

View file

@ -243,7 +243,7 @@ func (h *sentPacketHandler) SentPacket(p *Packet) {
}
pnSpace.largestSent = p.PacketNumber
isAckEliciting := len(p.Frames) > 0
isAckEliciting := len(p.StreamFrames) > 0 || len(p.Frames) > 0
if isAckEliciting {
pnSpace.lastAckElicitingPacketTime = p.SendTime
@ -424,6 +424,9 @@ func (h *sentPacketHandler) detectAndRemoveAckedPackets(ack *wire.AckFrame, encL
f.OnAcked(f.Frame)
}
}
for _, f := range p.StreamFrames {
f.Handler.OnAcked(f.Frame)
}
if err := pnSpace.history.Remove(p.PacketNumber); err != nil {
return nil, err
}
@ -790,12 +793,16 @@ func (h *sentPacketHandler) QueueProbePacket(encLevel protocol.EncryptionLevel)
}
func (h *sentPacketHandler) queueFramesForRetransmission(p *Packet) {
if len(p.Frames) == 0 {
if len(p.Frames) == 0 && len(p.StreamFrames) == 0 {
panic("no frames")
}
for _, f := range p.Frames {
f.OnLost(f.Frame)
}
for _, f := range p.StreamFrames {
f.Handler.OnLost(f.Frame)
}
p.StreamFrames = nil
p.Frames = nil
}