add different TCP timeouts for internal and incoming (#10090)

closes #10086
master
Harshavardhana 4 years ago committed by GitHub
parent 7764c542f2
commit e2c71717f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      cmd/http/dial_linux.go
  2. 2
      cmd/http/dial_others.go
  3. 5
      cmd/http/listener.go

@ -27,7 +27,7 @@ import (
"golang.org/x/sys/unix" "golang.org/x/sys/unix"
) )
func setTCPParameters(c syscall.RawConn) error { func setInternalTCPParameters(c syscall.RawConn) error {
return c.Control(func(fdPtr uintptr) { return c.Control(func(fdPtr uintptr) {
// got socket file descriptor to set parameters. // got socket file descriptor to set parameters.
fd := int(fdPtr) fd := int(fdPtr)
@ -67,7 +67,7 @@ func NewCustomDialContext(dialTimeout time.Duration) DialContext {
dialer := &net.Dialer{ dialer := &net.Dialer{
Timeout: dialTimeout, Timeout: dialTimeout,
Control: func(network, address string, c syscall.RawConn) error { Control: func(network, address string, c syscall.RawConn) error {
return setTCPParameters(c) return setInternalTCPParameters(c)
}, },
} }
return dialer.DialContext(ctx, network, addr) return dialer.DialContext(ctx, network, addr)

@ -26,7 +26,7 @@ import (
) )
// TODO: if possible implement for non-linux platforms, not a priority at the moment // TODO: if possible implement for non-linux platforms, not a priority at the moment
func setTCPParameters(c syscall.RawConn) error { func setInternalTCPParameters(c syscall.RawConn) error {
return nil return nil
} }

@ -81,10 +81,7 @@ func (listener *httpListener) start() {
// Closure to handle single connection. // Closure to handle single connection.
handleConn := func(tcpConn *net.TCPConn, doneCh <-chan struct{}) { handleConn := func(tcpConn *net.TCPConn, doneCh <-chan struct{}) {
rawConn, err := tcpConn.SyscallConn() tcpConn.SetKeepAlive(true)
if err == nil {
setTCPParameters(rawConn)
}
send(acceptResult{tcpConn, nil}, doneCh) send(acceptResult{tcpConn, nil}, doneCh)
} }

Loading…
Cancel
Save