Fixes #31510
Change-Id: I601d114b617a055380bf3c805e2d9a9b0795b656
Reviewed-on: https://go-review.googlesource.com/c/go/+/175259
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
"time"
)
+// defaultTCPKeepAlive is a default constant value for TCPKeepAlive times
+// See golang.org/issue/31510
+const (
+ defaultTCPKeepAlive = 15 * time.Second
+)
+
// A Dialer contains options for connecting to an address.
//
// The zero value for each field is equivalent to dialing
setKeepAlive(tc.fd, true)
ka := d.KeepAlive
if d.KeepAlive == 0 {
- ka = 15 * time.Second
+ ka = defaultTCPKeepAlive
}
setKeepAlivePeriod(tc.fd, ka)
testHookSetKeepAlive(ka)
"context"
"io"
"os"
- "time"
)
func (c *TCPConn) readFrom(r io.Reader) (int64, error) {
setKeepAlive(fd, true)
ka := ln.lc.KeepAlive
if ln.lc.KeepAlive == 0 {
- ka = 3 * time.Minute
+ ka = defaultTCPKeepAlive
}
setKeepAlivePeriod(fd, ka)
}
"io"
"os"
"syscall"
- "time"
)
func sockaddrToTCP(sa syscall.Sockaddr) Addr {
setKeepAlive(fd, true)
ka := ln.lc.KeepAlive
if ln.lc.KeepAlive == 0 {
- ka = 3 * time.Minute
+ ka = defaultTCPKeepAlive
}
setKeepAlivePeriod(fd, ka)
}