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

closes #10086
This commit is contained in:
Harshavardhana 2020-07-19 17:16:12 -07:00 committed by GitHub
parent 7764c542f2
commit e2c71717f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 7 deletions

View File

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

View File

@ -26,7 +26,7 @@ import (
)
// 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
}

View File

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