hashicorp / yamux

Golang connection multiplexing library
Mozilla Public License 2.0
2.24k stars 236 forks source link

When MaxStreamWindowSize is larger than initialStreamWindow, should lead to short read #63

Open wllenyj opened 6 years ago

wllenyj commented 6 years ago

OpenStream call sendWindowUpdate, then sendWindowUpdate will sync window from client to server. incrSendWindow and wirte will happen race. if incrSendWindow first run it is ok, else will lead sendWindow is not the same value to recvWindow, will out of sync.

// session_test.go
func TestSendData_Large(t *testing.T) {
    cfg := testConf()
    cfg.MaxStreamWindowSize = 4 * 1024 
    // ...
}
// const.go
const (
    // initialStreamWindow is the initial stream window size
    initialStreamWindow uint32 = 1 * 1024
)
=== RUN   TestSendData_Large
--- FAIL: TestSendData_Large (5.00s)
        session_test.go:415: short read: 1024
        session_test.go:441: err: stream reset
panic: timeout [recovered]
        panic: timeout
wllenyj commented 6 years ago

if MaxStreamWindowSize is not used for like this issue, please close.