use separate streamsMaps for gQUIC and IETF QUIC

This is a lot of duplicate code for now, but it will make moving towards
the new stream ID mapping in IETF QUIC (and unidirectional streams) much
easier.
This commit is contained in:
Marten Seemann 2018-01-04 10:26:02 +07:00
parent 69437a0e78
commit a20e94ee16
5 changed files with 873 additions and 89 deletions

View file

@ -12,18 +12,6 @@ import (
"github.com/lucas-clemente/quic-go/qerr"
)
type streamManager interface {
GetOrOpenStream(protocol.StreamID) (streamI, error)
GetOrOpenSendStream(protocol.StreamID) (sendStreamI, error)
GetOrOpenReceiveStream(protocol.StreamID) (receiveStreamI, error)
OpenStream() (Stream, error)
OpenStreamSync() (Stream, error)
AcceptStream() (Stream, error)
DeleteStream(protocol.StreamID) error
UpdateLimits(*handshake.TransportParameters)
CloseWithError(error)
}
type streamsMap struct {
mutex sync.RWMutex
@ -49,12 +37,11 @@ type streamsMap struct {
var _ streamManager = &streamsMap{}
type streamLambda func(streamI) (bool, error)
type newStreamLambda func(protocol.StreamID) streamI
var errMapAccess = errors.New("streamsMap: Error accessing the streams map")
func newStreamsMap(newStream newStreamLambda, pers protocol.Perspective, ver protocol.VersionNumber) *streamsMap {
func newStreamsMap(newStream newStreamLambda, pers protocol.Perspective) streamManager {
// add some tolerance to the maximum incoming streams value
maxStreams := uint32(protocol.MaxIncomingStreams)
maxIncomingStreams := utils.MaxUint32(
@ -72,13 +59,6 @@ func newStreamsMap(newStream newStreamLambda, pers protocol.Perspective, ver pro
nextClientInitiatedStream := protocol.StreamID(1)
nextServerInitiatedStream := protocol.StreamID(2)
if !ver.UsesTLS() {
nextServerInitiatedStream = 2
nextClientInitiatedStream = 3
if pers == protocol.PerspectiveServer {
sm.highestStreamOpenedByPeer = 1
}
}
if pers == protocol.PerspectiveServer {
sm.nextStreamToOpen = nextServerInitiatedStream
sm.nextStreamToAccept = nextClientInitiatedStream