Skip to content

Commit

Permalink
set stream max windows size to sockbuff
Browse files Browse the repository at this point in the history
  • Loading branch information
xtaci committed Aug 11, 2016
1 parent cf7bca5 commit d158e6d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ func main() {
EnableKeepAlive: true,
KeepAliveInterval: 30 * time.Second,
ConnectionWriteTimeout: 30 * time.Second,
MaxStreamWindowSize: 16777216,
MaxStreamWindowSize: uint32(sockbuf),
LogOutput: os.Stderr,
}
var session *yamux.Session
Expand Down
24 changes: 12 additions & 12 deletions server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,10 @@ func newCompStream(conn net.Conn) *compStream {
}

// handle multiplex-ed connection
func handleMux(conn io.ReadWriteCloser, target string) {
func handleMux(conn io.ReadWriteCloser, target string, config *yamux.Config) {
// stream multiplex
var mux *yamux.Session
config := &yamux.Config{
AcceptBacklog: 256,
EnableKeepAlive: true,
KeepAliveInterval: 30 * time.Second,
ConnectionWriteTimeout: 30 * time.Second,
MaxStreamWindowSize: 16777216,
LogOutput: os.Stderr,
}

m, err := yamux.Server(conn, config)
if err != nil {
log.Println(err)
Expand Down Expand Up @@ -276,7 +269,14 @@ func main() {
if err := lis.SetWriteBuffer(sockbuf); err != nil {
log.Println("SetWriteBuffer:", err)
}

config := &yamux.Config{
AcceptBacklog: 256,
EnableKeepAlive: true,
KeepAliveInterval: 30 * time.Second,
ConnectionWriteTimeout: 30 * time.Second,
MaxStreamWindowSize: uint32(sockbuf),
LogOutput: os.Stderr,
}
for {
if conn, err := lis.Accept(); err == nil {
log.Println("remote address:", conn.RemoteAddr())
Expand All @@ -288,9 +288,9 @@ func main() {
conn.SetKeepAlive(keepalive)

if nocomp {
go handleMux(conn, target)
go handleMux(conn, target, config)
} else {
go handleMux(newCompStream(conn), target)
go handleMux(newCompStream(conn), target, config)
}
} else {
log.Println(err)
Expand Down

0 comments on commit d158e6d

Please sign in to comment.