mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 21:44:03 +03:00
Deprecate bufferSize
This commit is contained in:
+5
-13
@@ -9,8 +9,6 @@ import (
|
||||
|
||||
type defaultDialer struct {
|
||||
net.Dialer
|
||||
|
||||
bufferSize int
|
||||
}
|
||||
|
||||
func (d *defaultDialer) Dial(network, address string) (net.Conn, error) {
|
||||
@@ -30,7 +28,7 @@ func (d *defaultDialer) DialContext(ctx context.Context, network, address string
|
||||
}
|
||||
|
||||
// we do not need to call to end user. End users call us.
|
||||
if err := SetServerSocketOptions(conn, d.bufferSize); err != nil {
|
||||
if err := SetServerSocketOptions(conn, 0); err != nil {
|
||||
conn.Close()
|
||||
|
||||
return nil, fmt.Errorf("cannot set socket options: %w", err)
|
||||
@@ -44,26 +42,20 @@ func (d *defaultDialer) DialContext(ctx context.Context, network, address string
|
||||
//
|
||||
// The most default one you can imagine. But it has tunes TCP
|
||||
// connections and setups SO_REUSEPORT.
|
||||
//
|
||||
// bufferSize is deprecated and ignored. It is kept here for backward
|
||||
// compatibility.
|
||||
func NewDefaultDialer(timeout time.Duration, bufferSize int) (Dialer, error) {
|
||||
switch {
|
||||
case timeout < 0:
|
||||
return nil, fmt.Errorf("timeout %v should be positive number", timeout)
|
||||
case bufferSize < 0:
|
||||
return nil, fmt.Errorf("buffer size %d should be positive number", bufferSize)
|
||||
}
|
||||
|
||||
if timeout == 0 {
|
||||
case timeout == 0:
|
||||
timeout = DefaultTimeout
|
||||
}
|
||||
|
||||
if bufferSize == 0 {
|
||||
bufferSize = DefaultBufferSize
|
||||
}
|
||||
|
||||
return &defaultDialer{
|
||||
Dialer: net.Dialer{
|
||||
Timeout: timeout,
|
||||
},
|
||||
bufferSize: bufferSize,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user