Increase the keep alive timeout to 30 secs (#6924)

Go by default uses a 3 * minute, we should
atleast use 30 secs as 10 secs is too aggressive.
master
Harshavardhana 6 years ago committed by Nitish Tiwari
parent 78a0fd951e
commit 3e124315c8
  1. 6
      cmd/http/listener.go
  2. 9
      cmd/http/listener_test.go
  3. 2
      cmd/http/server.go

@ -178,6 +178,9 @@ type httpListener struct {
// isRoutineNetErr returns true if error is due to a network timeout, // isRoutineNetErr returns true if error is due to a network timeout,
// connect reset or io.EOF and false otherwise // connect reset or io.EOF and false otherwise
func isRoutineNetErr(err error) bool { func isRoutineNetErr(err error) bool {
if err == nil {
return false
}
if nErr, ok := err.(*net.OpError); ok { if nErr, ok := err.(*net.OpError); ok {
// Check if the error is a tcp connection reset // Check if the error is a tcp connection reset
if syscallErr, ok := nErr.Err.(*os.SyscallError); ok { if syscallErr, ok := nErr.Err.(*os.SyscallError); ok {
@ -188,7 +191,8 @@ func isRoutineNetErr(err error) bool {
// Check if the error is a timeout // Check if the error is a timeout
return nErr.Timeout() return nErr.Timeout()
} }
return err == io.EOF // check for io.EOF and also some times io.EOF is wrapped is another error type.
return err == io.EOF || err.Error() == "EOF"
} }
// start - starts separate goroutine for each TCP listener. A valid insecure/TLS HTTP new connection is passed to httpListener.acceptCh. // start - starts separate goroutine for each TCP listener. A valid insecure/TLS HTTP new connection is passed to httpListener.acceptCh.

@ -20,6 +20,7 @@ import (
"bufio" "bufio"
"bytes" "bytes"
"crypto/tls" "crypto/tls"
"errors"
"fmt" "fmt"
"io" "io"
"net" "net"
@ -801,6 +802,10 @@ func TestIgnoreErr(t *testing.T) {
err: &net.OpError{Err: &myTimeoutErr{timeout: true}}, err: &net.OpError{Err: &myTimeoutErr{timeout: true}},
want: true, want: true,
}, },
{
err: errors.New("EOF"),
want: true,
},
{ {
err: &net.OpError{Err: &myTimeoutErr{timeout: false}}, err: &net.OpError{Err: &myTimeoutErr{timeout: false}},
want: false, want: false,
@ -809,6 +814,10 @@ func TestIgnoreErr(t *testing.T) {
err: io.ErrUnexpectedEOF, err: io.ErrUnexpectedEOF,
want: false, want: false,
}, },
{
err: nil,
want: false,
},
} }
for i, tc := range testCases { for i, tc := range testCases {

@ -36,7 +36,7 @@ const (
DefaultShutdownTimeout = 5 * time.Second DefaultShutdownTimeout = 5 * time.Second
// DefaultTCPKeepAliveTimeout - default TCP keep alive timeout for accepted connection. // DefaultTCPKeepAliveTimeout - default TCP keep alive timeout for accepted connection.
DefaultTCPKeepAliveTimeout = 10 * time.Second DefaultTCPKeepAliveTimeout = 30 * time.Second
// DefaultReadTimeout - default timout to read data from accepted connection. // DefaultReadTimeout - default timout to read data from accepted connection.
DefaultReadTimeout = 5 * time.Minute DefaultReadTimeout = 5 * time.Minute

Loading…
Cancel
Save