forked from quic-go/quic-go
simplify frame queuing logic on 0-RTT rejection (#4607)
Even though we currently don't do so, sending MAX_DATA, MAX_STREAM_DATA and MAX_STREAMS is allowed in 0-RTT.
This commit is contained in:
@@ -1675,10 +1675,8 @@ func (s *connection) dropEncryptionLevel(encLevel protocol.EncryptionLevel) erro
|
||||
s.cryptoStreamHandler.DiscardInitialKeys()
|
||||
case protocol.Encryption0RTT:
|
||||
s.streamsMap.ResetFor0RTT()
|
||||
if err := s.connFlowController.Reset(); err != nil {
|
||||
return err
|
||||
}
|
||||
return s.framer.Handle0RTTRejection()
|
||||
s.framer.Handle0RTTRejection()
|
||||
return s.connFlowController.Reset()
|
||||
}
|
||||
return s.cryptoStreamManager.Drop(encLevel)
|
||||
}
|
||||
|
||||
16
framer.go
16
framer.go
@@ -1,7 +1,7 @@
|
||||
package quic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"slices"
|
||||
"sync"
|
||||
|
||||
"github.com/quic-go/quic-go/internal/ackhandler"
|
||||
@@ -171,11 +171,12 @@ func (f *framer) AppendStreamFrames(frames []ackhandler.StreamFrame, maxLen prot
|
||||
return frames, length
|
||||
}
|
||||
|
||||
func (f *framer) Handle0RTTRejection() error {
|
||||
func (f *framer) Handle0RTTRejection() {
|
||||
f.mutex.Lock()
|
||||
defer f.mutex.Unlock()
|
||||
|
||||
f.controlFrameMutex.Lock()
|
||||
defer f.controlFrameMutex.Unlock()
|
||||
|
||||
f.streamQueue.Clear()
|
||||
for id := range f.activeStreams {
|
||||
delete(f.activeStreams, id)
|
||||
@@ -183,16 +184,13 @@ func (f *framer) Handle0RTTRejection() error {
|
||||
var j int
|
||||
for i, frame := range f.controlFrames {
|
||||
switch frame.(type) {
|
||||
case *wire.MaxDataFrame, *wire.MaxStreamDataFrame, *wire.MaxStreamsFrame:
|
||||
return errors.New("didn't expect MAX_DATA / MAX_STREAM_DATA / MAX_STREAMS frame to be sent in 0-RTT")
|
||||
case *wire.DataBlockedFrame, *wire.StreamDataBlockedFrame, *wire.StreamsBlockedFrame:
|
||||
case *wire.MaxDataFrame, *wire.MaxStreamDataFrame, *wire.MaxStreamsFrame,
|
||||
*wire.DataBlockedFrame, *wire.StreamDataBlockedFrame, *wire.StreamsBlockedFrame:
|
||||
continue
|
||||
default:
|
||||
f.controlFrames[j] = f.controlFrames[i]
|
||||
j++
|
||||
}
|
||||
}
|
||||
f.controlFrames = f.controlFrames[:j]
|
||||
f.controlFrameMutex.Unlock()
|
||||
return nil
|
||||
f.controlFrames = slices.Delete(f.controlFrames, j, len(f.controlFrames))
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ var _ = Describe("Framer", func() {
|
||||
for _, f := range frames {
|
||||
framer.QueueControlFrame(f)
|
||||
}
|
||||
Expect(framer.Handle0RTTRejection()).To(Succeed())
|
||||
framer.Handle0RTTRejection()
|
||||
fs, length := framer.AppendControlFrames(nil, protocol.MaxByteCount, protocol.Version1)
|
||||
Expect(fs).To(HaveLen(2))
|
||||
Expect(length).To(Equal(ping.Length(version) + ncid.Length(version)))
|
||||
@@ -424,7 +424,7 @@ var _ = Describe("Framer", func() {
|
||||
|
||||
It("drops all STREAM frames when 0-RTT is rejected", func() {
|
||||
framer.AddActiveStream(id1, stream1)
|
||||
Expect(framer.Handle0RTTRejection()).To(Succeed())
|
||||
framer.Handle0RTTRejection()
|
||||
fs, length := framer.AppendStreamFrames(nil, protocol.MaxByteCount, protocol.Version1)
|
||||
Expect(fs).To(BeEmpty())
|
||||
Expect(length).To(BeZero())
|
||||
|
||||
Reference in New Issue
Block a user