Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add token into stream v2 #47

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
44c7a42
move token into stream
cs8425 Apr 24, 2017
c6b175f
add option to enable/disable StreamBuffer
cs8425 Apr 26, 2017
41aab74
change for initial boost
cs8425 Apr 27, 2017
e627166
boost for Slow-Start Restart (SSR)
cs8425 Apr 27, 2017
332d9f5
fix deadlock when timeout/BrokenPipe with Stream buffer full & add Sl…
cs8425 Apr 29, 2017
b9af5ff
add custom CMD
cs8425 Oct 8, 2016
ed0e3d8
change formula for guessing when to send cmdFUL, cmdEMP
cs8425 Apr 29, 2017
74c4ad6
fix close before read out all data
cs8425 May 18, 2017
f3052f7
fix division by zero & Read with zero length buffer
cs8425 Jun 9, 2017
f86d348
fix race at resumeWrite() and Write()
cs8425 Jul 30, 2017
47996e3
change default setting
cs8425 Sep 26, 2017
7c09715
fix random stream freeze
cs8425 Jan 4, 2018
2b51cee
add more test & fix net.Pipe() freeze issue
cs8425 Jan 4, 2018
4053dea
fix bug: read 0 bytes from a stream will block forever #27 by longzhiri
cs8425 Mar 5, 2018
3ac8418
export RTT of Session
cs8425 Oct 14, 2018
4247797
Merge & fix from upstram xtaci/v1.1.1
cs8425 Mar 6, 2019
6ea9ca4
add more test base on net.Pipe()
cs8425 Mar 6, 2019
7f8c639
immediately send a ping after Session initial
cs8425 Mar 6, 2019
70c47ac
add more test
cs8425 Mar 6, 2019
4f20cbb
fix data racing & change keepalive implement
cs8425 Mar 7, 2019
ad68e27
some clean up
cs8425 Mar 7, 2019
a5a26dc
fix dead lock when use with net.Pipe()
cs8425 Mar 9, 2019
30cb0f9
add more test
cs8425 Mar 9, 2019
6c212a4
merge stream token & change keepalive implement
cs8425 Mar 9, 2019
ce5452b
change default config to close to upstream
cs8425 Mar 9, 2019
e406e19
add new KeepAlive test & fix KeepAlive
cs8425 Mar 9, 2019
2357420
fix another deadlock & add TestReadZeroLengthBuffer()
cs8425 Mar 9, 2019
aca63f5
try fix setupServer() and deadlock
cs8425 Mar 9, 2019
c005e6c
add test for Parallel Write & remove unsed
cs8425 Mar 10, 2019
480fe12
better test & fix Parallel Write
cs8425 Mar 10, 2019
1d77359
little clean up
cs8425 Mar 11, 2019
557683d
fix compitible of old version
cs8425 Mar 11, 2019
0e059d3
refactor keepalive() and keep compitible with old version & fix bench
cs8425 Mar 11, 2019
c7c6f9f
try fix race between cmdPSH and cmdFIN
cs8425 Mar 12, 2019
76bb771
add a deadlock test
cs8425 Mar 13, 2019
9d5a405
update test
cs8425 Mar 13, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
language: go
go:
- 1.9.x
- 1.10.x
- 1.11.x
- 1.12.x

before_install:
- go get -t -v ./...
Expand All @@ -11,7 +11,7 @@ install:
- go get github.com/xtaci/smux

script:
- go test -coverprofile=coverage.txt -covermode=atomic -bench .
- go test -coverprofile=coverage.txt -covermode=atomic -bench . -v

after_success:
- bash <(curl -s https://codecov.io/bash)
3 changes: 3 additions & 0 deletions frame.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ const ( // cmds
cmdFIN // stream close, a.k.a EOF mark
cmdPSH // data push
cmdNOP // no operation
cmdACK // for test RTT
cmdFUL // buffer full
cmdEMP // buffer empty
)

const (
Expand Down
27 changes: 19 additions & 8 deletions mux.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package smux

import (
"fmt"
"io"
"time"

Expand All @@ -24,15 +23,27 @@ type Config struct {
// MaxReceiveBuffer is used to control the maximum
// number of data in the buffer pool
MaxReceiveBuffer int

// Enable Stream buffer
EnableStreamBuffer bool

// maximum bytes that each Stream can use
MaxStreamBuffer int

// for initial boost
BoostTimeout time.Duration
}

// DefaultConfig is used to return a default configuration
func DefaultConfig() *Config {
return &Config{
KeepAliveInterval: 10 * time.Second,
KeepAliveTimeout: 30 * time.Second,
MaxFrameSize: 32768,
MaxReceiveBuffer: 4194304,
KeepAliveInterval: 2500 * time.Millisecond,
KeepAliveTimeout: 7500 * time.Millisecond, // RTT usually < 7500ms
MaxFrameSize: 32768,
MaxReceiveBuffer: 4 * 1024 * 1024,
EnableStreamBuffer: true,
MaxStreamBuffer: 200 * 8 * 1024,
BoostTimeout: 10 * time.Second,
}
}

Expand All @@ -41,9 +52,6 @@ func VerifyConfig(config *Config) error {
if config.KeepAliveInterval == 0 {
return errors.New("keep-alive interval must be positive")
}
if config.KeepAliveTimeout < config.KeepAliveInterval {
return fmt.Errorf("keep-alive timeout must be larger than keep-alive interval")
}
if config.MaxFrameSize <= 0 {
return errors.New("max frame size must be positive")
}
Expand All @@ -53,6 +61,9 @@ func VerifyConfig(config *Config) error {
if config.MaxReceiveBuffer <= 0 {
return errors.New("max receive buffer must be positive")
}
if config.MaxStreamBuffer <= 0 {
return errors.New("max stream receive buffer must be positive")
}
return nil
}

Expand Down
9 changes: 4 additions & 5 deletions mux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,31 @@ func TestConfig(t *testing.T) {
}

config = DefaultConfig()
config.KeepAliveInterval = 10
config.KeepAliveTimeout = 5
config.MaxFrameSize = 0
err = VerifyConfig(config)
t.Log(err)
if err == nil {
t.Fatal(err)
}

config = DefaultConfig()
config.MaxFrameSize = 0
config.MaxFrameSize = 65536
err = VerifyConfig(config)
t.Log(err)
if err == nil {
t.Fatal(err)
}

config = DefaultConfig()
config.MaxFrameSize = 65536
config.MaxReceiveBuffer = 0
err = VerifyConfig(config)
t.Log(err)
if err == nil {
t.Fatal(err)
}

config = DefaultConfig()
config.MaxReceiveBuffer = 0
config.MaxStreamBuffer = 0
err = VerifyConfig(config)
t.Log(err)
if err == nil {
Expand Down
Loading