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

feat: update MaxWriteBufferSize comment and MaxWriteBufferSize default check #427

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const (
DefaultReadBufferSize = 1024 * 64

// DefaultMaxWriteBufferSize .
DefaultMaxWriteBufferSize = 1024 * 1024
DefaultMaxWriteBufferSize = 0

// DefaultMaxConnReadTimesPerEventLoop .
DefaultMaxConnReadTimesPerEventLoop = 3
Expand Down Expand Up @@ -67,8 +67,8 @@ type Config struct {
// ReadBufferSize represents buffer size for reading, it's set to 64k by default.
ReadBufferSize int

// MaxWriteBufferSize represents max write buffer size for Conn, it's set to 1m by default.
// if the connection's Send-Q is full and the data cached by nbio is
// MaxWriteBufferSize represents max write buffer size for Conn, 0 by default, represents no limit for writeBuffer
// if MaxWriteBufferSize is set greater than to 0, and the connection's Send-Q is full and the data cached by nbio is
// more than MaxWriteBufferSize, the connection would be closed by nbio.
MaxWriteBufferSize int

Expand Down
3 changes: 3 additions & 0 deletions engine_std.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ func NewEngine(conf Config) *Engine {
if conf.ReadBufferSize <= 0 {
conf.ReadBufferSize = DefaultReadBufferSize
}
if conf.MaxWriteBufferSize < 0 {
conf.MaxWriteBufferSize = DefaultMaxWriteBufferSize
}
if conf.Listen == nil {
conf.Listen = net.Listen
}
Expand Down
3 changes: 3 additions & 0 deletions engine_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,9 @@ func NewEngine(conf Config) *Engine {
if conf.ReadBufferSize <= 0 {
conf.ReadBufferSize = DefaultReadBufferSize
}
if conf.MaxWriteBufferSize < 0 {
conf.MaxWriteBufferSize = DefaultMaxWriteBufferSize
}
if conf.MaxConnReadTimesPerEventLoop <= 0 {
conf.MaxConnReadTimesPerEventLoop = DefaultMaxConnReadTimesPerEventLoop
}
Expand Down
4 changes: 2 additions & 2 deletions nbhttp/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ type Config struct {
// ReadBufferSize represents buffer size for reading, it's set to 64k by default.
ReadBufferSize int

// MaxWriteBufferSize represents max write buffer size for Conn, it's set to 1m by default.
// if the connection's Send-Q is full and the data cached by nbio is
// MaxWriteBufferSize represents max write buffer size for Conn, 0 by default, represents no limit for writeBuffer
// if MaxWriteBufferSize is set greater than to 0, and the connection's Send-Q is full and the data cached by nbio is
// more than MaxWriteBufferSize, the connection would be closed by nbio.
MaxWriteBufferSize int

Expand Down
Loading