set initial flow control window from handshake parameters

fixes #50
This commit is contained in:
Marten Seemann
2016-05-05 11:29:12 +07:00
parent d178a02ad8
commit 77f34a9207
6 changed files with 70 additions and 12 deletions

View File

@@ -6,6 +6,7 @@ import (
"sync/atomic"
"github.com/lucas-clemente/quic-go/frames"
"github.com/lucas-clemente/quic-go/handshake"
"github.com/lucas-clemente/quic-go/protocol"
"github.com/lucas-clemente/quic-go/utils"
)
@@ -29,19 +30,28 @@ type stream struct {
remoteErr error
currentErr error
connectionParameterManager *handshake.ConnectionParametersManager
flowControlWindow uint64
windowUpdateCond *sync.Cond
}
// newStream creates a new Stream
func newStream(session streamHandler, StreamID protocol.StreamID) *stream {
return &stream{
session: session,
streamID: StreamID,
streamFrames: make(chan *frames.StreamFrame, 8), // ToDo: add config option for this number
flowControlWindow: 0x4000, // 16 byte, TODO: read this from the negotiated connection parameters (TagCFCW)
windowUpdateCond: sync.NewCond(&sync.Mutex{}),
func newStream(session streamHandler, connectionParameterManager *handshake.ConnectionParametersManager, StreamID protocol.StreamID) (*stream, error) {
s := &stream{
session: session,
streamID: StreamID,
streamFrames: make(chan *frames.StreamFrame, 8), // ToDo: add config option for this number
connectionParameterManager: connectionParameterManager,
windowUpdateCond: sync.NewCond(&sync.Mutex{}),
}
flowControlWindow, err := connectionParameterManager.GetStreamFlowControlWindow()
if err != nil {
return nil, err
}
s.flowControlWindow = uint64(flowControlWindow)
return s, nil
}
// Read implements io.Reader