Deprecate bufferSize

This commit is contained in:
9seconds
2021-11-28 17:58:14 +03:00
parent bae5407372
commit d19cfb1df4
11 changed files with 30 additions and 55 deletions
+5 -13
View File
@@ -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
}