remove unused framer interface (#4599)

No functional change expected.
This commit is contained in:
Marten Seemann
2024-07-24 17:55:09 -06:00
committed by GitHub
parent 9b70412b0f
commit fc79a77ffe
3 changed files with 20 additions and 36 deletions

View File

@@ -144,7 +144,7 @@ type connection struct {
sentPacketHandler ackhandler.SentPacketHandler
receivedPacketHandler ackhandler.ReceivedPacketHandler
retransmissionQueue *retransmissionQueue
framer framer
framer *framer
windowUpdateQueue *windowUpdateQueue
connFlowController flowcontrol.ConnectionFlowController
tokenStoreKey string // only set for the client

View File

@@ -11,31 +11,12 @@ import (
"github.com/quic-go/quic-go/quicvarint"
)
type framer interface {
HasData() bool
QueueControlFrame(wire.Frame)
AppendControlFrames([]ackhandler.Frame, protocol.ByteCount, protocol.Version) ([]ackhandler.Frame, protocol.ByteCount)
AddActiveStream(protocol.StreamID)
AppendStreamFrames([]ackhandler.StreamFrame, protocol.ByteCount, protocol.Version) ([]ackhandler.StreamFrame, protocol.ByteCount)
Handle0RTTRejection() error
// QueuedTooManyControlFrames says if the control frame queue exceeded its maximum queue length.
// This is a hack.
// It is easier to implement than propagating an error return value in QueueControlFrame.
// The correct solution would be to queue frames with their respective structs.
// See https://github.com/quic-go/quic-go/issues/4271 for the queueing of stream-related control frames.
QueuedTooManyControlFrames() bool
}
const (
maxPathResponses = 256
maxControlFrames = 16 << 10
)
type framerI struct {
type framer struct {
mutex sync.Mutex
streamGetter streamGetter
@@ -49,16 +30,14 @@ type framerI struct {
queuedTooManyControlFrames bool
}
var _ framer = &framerI{}
func newFramer(streamGetter streamGetter) framer {
return &framerI{
func newFramer(streamGetter streamGetter) *framer {
return &framer{
streamGetter: streamGetter,
activeStreams: make(map[protocol.StreamID]struct{}),
}
}
func (f *framerI) HasData() bool {
func (f *framer) HasData() bool {
f.mutex.Lock()
hasData := !f.streamQueue.Empty()
f.mutex.Unlock()
@@ -70,7 +49,7 @@ func (f *framerI) HasData() bool {
return len(f.controlFrames) > 0 || len(f.pathResponses) > 0
}
func (f *framerI) QueueControlFrame(frame wire.Frame) {
func (f *framer) QueueControlFrame(frame wire.Frame) {
f.controlFrameMutex.Lock()
defer f.controlFrameMutex.Unlock()
@@ -92,7 +71,7 @@ func (f *framerI) QueueControlFrame(frame wire.Frame) {
f.controlFrames = append(f.controlFrames, frame)
}
func (f *framerI) AppendControlFrames(frames []ackhandler.Frame, maxLen protocol.ByteCount, v protocol.Version) ([]ackhandler.Frame, protocol.ByteCount) {
func (f *framer) AppendControlFrames(frames []ackhandler.Frame, maxLen protocol.ByteCount, v protocol.Version) ([]ackhandler.Frame, protocol.ByteCount) {
f.controlFrameMutex.Lock()
defer f.controlFrameMutex.Unlock()
@@ -121,11 +100,16 @@ func (f *framerI) AppendControlFrames(frames []ackhandler.Frame, maxLen protocol
return frames, length
}
func (f *framerI) QueuedTooManyControlFrames() bool {
// QueuedTooManyControlFrames says if the control frame queue exceeded its maximum queue length.
// This is a hack.
// It is easier to implement than propagating an error return value in QueueControlFrame.
// The correct solution would be to queue frames with their respective structs.
// See https://github.com/quic-go/quic-go/issues/4271 for the queueing of stream-related control frames.
func (f *framer) QueuedTooManyControlFrames() bool {
return f.queuedTooManyControlFrames
}
func (f *framerI) AddActiveStream(id protocol.StreamID) {
func (f *framer) AddActiveStream(id protocol.StreamID) {
f.mutex.Lock()
if _, ok := f.activeStreams[id]; !ok {
f.streamQueue.PushBack(id)
@@ -134,7 +118,7 @@ func (f *framerI) AddActiveStream(id protocol.StreamID) {
f.mutex.Unlock()
}
func (f *framerI) AppendStreamFrames(frames []ackhandler.StreamFrame, maxLen protocol.ByteCount, v protocol.Version) ([]ackhandler.StreamFrame, protocol.ByteCount) {
func (f *framer) AppendStreamFrames(frames []ackhandler.StreamFrame, maxLen protocol.ByteCount, v protocol.Version) ([]ackhandler.StreamFrame, protocol.ByteCount) {
startLen := len(frames)
var length protocol.ByteCount
f.mutex.Lock()
@@ -183,7 +167,7 @@ func (f *framerI) AppendStreamFrames(frames []ackhandler.StreamFrame, maxLen pro
return frames, length
}
func (f *framerI) Handle0RTTRejection() error {
func (f *framer) Handle0RTTRejection() error {
f.mutex.Lock()
defer f.mutex.Unlock()

View File

@@ -21,7 +21,7 @@ var _ = Describe("Framer", func() {
)
var (
framer framer
framer *framer
stream1, stream2 *MockSendStreamI
streamGetter *MockStreamGetter
version protocol.Version
@@ -117,14 +117,14 @@ var _ = Describe("Framer", func() {
Expect(framer.QueuedTooManyControlFrames()).To(BeFalse())
frames, _ := framer.AppendControlFrames([]ackhandler.Frame{}, 1, protocol.Version1)
Expect(frames).To(HaveLen(1))
Expect(framer.(*framerI).controlFrames).To(HaveLen(i + 1))
Expect(framer.controlFrames).To(HaveLen(i + 1))
}
framer.QueueControlFrame(&wire.PingFrame{})
Expect(framer.QueuedTooManyControlFrames()).To(BeFalse())
Expect(framer.(*framerI).controlFrames).To(HaveLen(maxControlFrames))
Expect(framer.controlFrames).To(HaveLen(maxControlFrames))
framer.QueueControlFrame(&wire.PingFrame{})
Expect(framer.QueuedTooManyControlFrames()).To(BeTrue())
Expect(framer.(*framerI).controlFrames).To(HaveLen(maxControlFrames))
Expect(framer.controlFrames).To(HaveLen(maxControlFrames))
})
})