use a uint64 for stream counts

This commit is contained in:
Marten Seemann
2018-11-09 09:00:25 +07:00
parent e8de94485c
commit 0f931ca54e
7 changed files with 34 additions and 17 deletions

View File

@@ -21,7 +21,7 @@ type incomingBidiStreamsMap struct {
nextStreamToAccept protocol.StreamID // the next stream that will be returned by AcceptStream()
nextStreamToOpen protocol.StreamID // the highest stream that the peer openend
maxStream protocol.StreamID // the highest stream that the peer is allowed to open
maxNumStreams int // maximum number of streams
maxNumStreams uint64 // maximum number of streams
newStream func(protocol.StreamID) streamI
queueMaxStreamID func(*wire.MaxStreamIDFrame)
@@ -32,7 +32,7 @@ type incomingBidiStreamsMap struct {
func newIncomingBidiStreamsMap(
nextStreamToAccept protocol.StreamID,
initialMaxStreamID protocol.StreamID,
maxNumStreams int,
maxNumStreams uint64,
queueControlFrame func(wire.Frame),
newStream func(protocol.StreamID) streamI,
) *incomingBidiStreamsMap {
@@ -108,7 +108,8 @@ func (m *incomingBidiStreamsMap) DeleteStream(id protocol.StreamID) error {
}
delete(m.streams, id)
// queue a MAX_STREAM_ID frame, giving the peer the option to open a new stream
if numNewStreams := m.maxNumStreams - len(m.streams); numNewStreams > 0 {
if m.maxNumStreams > uint64(len(m.streams)) {
numNewStreams := m.maxNumStreams - uint64(len(m.streams))
m.maxStream = m.nextStreamToOpen + protocol.StreamID((numNewStreams-1)*4)
m.queueMaxStreamID(&wire.MaxStreamIDFrame{StreamID: m.maxStream})
}