forked from quic-go/quic-go
simplify the maximum stream limit
This commit is contained in:
@@ -39,13 +39,13 @@ type paramsNegotiatorBase struct {
|
||||
omitConnectionID bool
|
||||
requestConnectionIDOmission bool
|
||||
|
||||
maxIncomingDynamicStreamsPerConnection uint32
|
||||
idleTimeout time.Duration
|
||||
remoteIdleTimeout time.Duration
|
||||
sendStreamFlowControlWindow protocol.ByteCount
|
||||
sendConnectionFlowControlWindow protocol.ByteCount
|
||||
receiveStreamFlowControlWindow protocol.ByteCount
|
||||
receiveConnectionFlowControlWindow protocol.ByteCount
|
||||
maxOutgoingStreams uint32
|
||||
idleTimeout time.Duration
|
||||
remoteIdleTimeout time.Duration
|
||||
sendStreamFlowControlWindow protocol.ByteCount
|
||||
sendConnectionFlowControlWindow protocol.ByteCount
|
||||
receiveStreamFlowControlWindow protocol.ByteCount
|
||||
receiveConnectionFlowControlWindow protocol.ByteCount
|
||||
}
|
||||
|
||||
func (h *paramsNegotiatorBase) init(params *TransportParameters) {
|
||||
@@ -56,15 +56,8 @@ func (h *paramsNegotiatorBase) init(params *TransportParameters) {
|
||||
h.requestConnectionIDOmission = params.RequestConnectionIDOmission
|
||||
|
||||
h.idleTimeout = params.IdleTimeout
|
||||
if h.perspective == protocol.PerspectiveServer {
|
||||
h.maxIncomingDynamicStreamsPerConnection = protocol.MaxStreamsPerConnection // "incoming" seen from the client's perspective
|
||||
} else {
|
||||
h.maxIncomingDynamicStreamsPerConnection = protocol.MaxStreamsPerConnection // "incoming" seen from the server's perspective
|
||||
}
|
||||
}
|
||||
|
||||
func (h *paramsNegotiatorBase) negotiateMaxIncomingDynamicStreamsPerConnection(clientValue uint32) uint32 {
|
||||
return utils.MinUint32(clientValue, protocol.MaxIncomingDynamicStreamsPerConnection)
|
||||
// use this as a default value. As soon as the client sends its value, this gets updated
|
||||
h.maxOutgoingStreams = protocol.MaxOutgoingStreams
|
||||
}
|
||||
|
||||
// GetSendStreamFlowControlWindow gets the size of the stream-level flow control window for sending data
|
||||
@@ -97,8 +90,11 @@ func (h *paramsNegotiatorBase) GetReceiveConnectionFlowControlWindow() protocol.
|
||||
func (h *paramsNegotiatorBase) GetMaxOutgoingStreams() uint32 {
|
||||
h.mutex.RLock()
|
||||
defer h.mutex.RUnlock()
|
||||
return h.maxOutgoingStreams
|
||||
}
|
||||
|
||||
return h.maxIncomingDynamicStreamsPerConnection
|
||||
func (h *paramsNegotiatorBase) setMaxOutgoingStreams(clientValue uint32) {
|
||||
h.maxOutgoingStreams = utils.MinUint32(clientValue, protocol.MaxOutgoingStreams)
|
||||
}
|
||||
|
||||
func (h *paramsNegotiatorBase) setRemoteIdleTimeout(t time.Duration) {
|
||||
|
||||
@@ -47,7 +47,7 @@ func (h *paramsNegotiatorGQUIC) SetFromMap(params map[Tag][]byte) error {
|
||||
if err != nil {
|
||||
return errMalformedTag
|
||||
}
|
||||
h.maxIncomingDynamicStreamsPerConnection = h.negotiateMaxIncomingDynamicStreamsPerConnection(clientValue)
|
||||
h.setMaxOutgoingStreams(clientValue)
|
||||
}
|
||||
if value, ok := params[TagICSL]; ok {
|
||||
clientValue, err := utils.LittleEndian.ReadUint32(bytes.NewBuffer(value))
|
||||
@@ -93,7 +93,7 @@ func (h *paramsNegotiatorGQUIC) GetHelloMap() (map[Tag][]byte, error) {
|
||||
cfcw := bytes.NewBuffer([]byte{})
|
||||
utils.LittleEndian.WriteUint32(cfcw, uint32(h.GetReceiveConnectionFlowControlWindow()))
|
||||
mids := bytes.NewBuffer([]byte{})
|
||||
utils.LittleEndian.WriteUint32(mids, protocol.MaxIncomingDynamicStreamsPerConnection)
|
||||
utils.LittleEndian.WriteUint32(mids, protocol.MaxIncomingStreams)
|
||||
icsl := bytes.NewBuffer([]byte{})
|
||||
utils.LittleEndian.WriteUint32(icsl, uint32(h.idleTimeout/time.Second))
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ var _ = Describe("Params Negotiator (for gQUIC)", func() {
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
entryMap, err := pn.GetHelloMap()
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
Expect(entryMap[TagMIDS]).To(Equal([]byte{byte(protocol.MaxIncomingDynamicStreamsPerConnection), 0, 0, 0}))
|
||||
Expect(entryMap[TagMIDS]).To(Equal([]byte{byte(protocol.MaxIncomingStreams), 0, 0, 0}))
|
||||
})
|
||||
})
|
||||
|
||||
@@ -88,7 +88,7 @@ var _ = Describe("Params Negotiator (for gQUIC)", func() {
|
||||
Expect(entryMap).To(HaveKey(TagICSL))
|
||||
Expect(binary.LittleEndian.Uint32(entryMap[TagICSL])).To(BeEquivalentTo(idleTimeout / time.Second))
|
||||
Expect(entryMap).To(HaveKey(TagMIDS))
|
||||
Expect(binary.LittleEndian.Uint32(entryMap[TagMIDS])).To(BeEquivalentTo(protocol.MaxIncomingDynamicStreamsPerConnection))
|
||||
Expect(binary.LittleEndian.Uint32(entryMap[TagMIDS])).To(BeEquivalentTo(protocol.MaxIncomingStreams))
|
||||
Expect(entryMap).To(HaveKey(TagSFCW))
|
||||
Expect(binary.LittleEndian.Uint32(entryMap[TagSFCW])).To(BeEquivalentTo(protocol.ReceiveStreamFlowControlWindow))
|
||||
Expect(entryMap).To(HaveKey(TagCFCW))
|
||||
|
||||
Reference in New Issue
Block a user