From 3e124315c8abd0e1fd33ffd9a7ca3c6314ad1032 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Thu, 6 Dec 2018 09:26:16 -0800 Subject: [PATCH] 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. --- cmd/http/listener.go | 6 +++++- cmd/http/listener_test.go | 9 +++++++++ cmd/http/server.go | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/cmd/http/listener.go b/cmd/http/listener.go index 5ca585ce2..462902c1f 100644 --- a/cmd/http/listener.go +++ b/cmd/http/listener.go @@ -178,6 +178,9 @@ type httpListener struct { // isRoutineNetErr returns true if error is due to a network timeout, // connect reset or io.EOF and false otherwise func isRoutineNetErr(err error) bool { + if err == nil { + return false + } if nErr, ok := err.(*net.OpError); ok { // Check if the error is a tcp connection reset if syscallErr, ok := nErr.Err.(*os.SyscallError); ok { @@ -188,7 +191,8 @@ func isRoutineNetErr(err error) bool { // Check if the error is a 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. diff --git a/cmd/http/listener_test.go b/cmd/http/listener_test.go index 9570048cc..741738807 100644 --- a/cmd/http/listener_test.go +++ b/cmd/http/listener_test.go @@ -20,6 +20,7 @@ import ( "bufio" "bytes" "crypto/tls" + "errors" "fmt" "io" "net" @@ -801,6 +802,10 @@ func TestIgnoreErr(t *testing.T) { err: &net.OpError{Err: &myTimeoutErr{timeout: true}}, want: true, }, + { + err: errors.New("EOF"), + want: true, + }, { err: &net.OpError{Err: &myTimeoutErr{timeout: false}}, want: false, @@ -809,6 +814,10 @@ func TestIgnoreErr(t *testing.T) { err: io.ErrUnexpectedEOF, want: false, }, + { + err: nil, + want: false, + }, } for i, tc := range testCases { diff --git a/cmd/http/server.go b/cmd/http/server.go index 746cf59c9..d4ee5e484 100644 --- a/cmd/http/server.go +++ b/cmd/http/server.go @@ -36,7 +36,7 @@ const ( DefaultShutdownTimeout = 5 * time.Second // 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 = 5 * time.Minute