Skip to content

Commit cbf90b0

Browse files
gmichelobradfitz
authored andcommitted
net: correct docs of KeepAlive field in Dialer type
KeepAlive field used to report the wording "keep-alive period" which may be misleading. This field does not represent the whole TCP keepalive time, that is the inactivity period upon which one endpoint starts probing the other end. But it acctually specifies the keepalive interval, that is the time between two keepalive probes. Fixes #29089 Change-Id: If99b38ba108830d0e5fe527171a2f5c96a3bcde7 Reviewed-on: https://go-review.googlesource.com/c/go/+/155960 Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent 76659e4 commit cbf90b0

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

src/net/dial.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,13 @@ type Dialer struct {
6363
// A negative value disables Fast Fallback support.
6464
FallbackDelay time.Duration
6565

66-
// KeepAlive specifies the keep-alive period for an active
67-
// network connection.
68-
// If zero, keep-alives are enabled if supported by the protocol
69-
// and operating system. Network protocols or operating systems
70-
// that do not support keep-alives ignore this field.
71-
// If negative, keep-alives are disabled.
66+
// KeepAlive specifies the interval between keep-alive
67+
// probes for an active network connection.
68+
// If zero, keep-alive probes are sent with a default value
69+
// (currently 15 seconds), if supported by the protocol and operating
70+
// system. Network protocols or operating systems that do
71+
// not support keep-alives ignore this field.
72+
// If negative, keep-alive probes are disabled.
7273
KeepAlive time.Duration
7374

7475
// Resolver optionally specifies an alternate resolver to use.

src/net/http/httputil/persist.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,8 @@ func (cc *ClientConn) Close() error {
292292
}
293293

294294
// Write writes a request. An ErrPersistEOF error is returned if the connection
295-
// has been closed in an HTTP keepalive sense. If req.Close equals true, the
296-
// keepalive connection is logically closed after this request and the opposing
295+
// has been closed in an HTTP keep-alive sense. If req.Close equals true, the
296+
// keep-alive connection is logically closed after this request and the opposing
297297
// server is informed. An ErrUnexpectedEOF indicates the remote closed the
298298
// underlying TCP connection, which is usually considered as graceful close.
299299
func (cc *ClientConn) Write(req *http.Request) error {

src/net/tcpsock.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func (c *TCPConn) SetLinger(sec int) error {
154154
}
155155

156156
// SetKeepAlive sets whether the operating system should send
157-
// keepalive messages on the connection.
157+
// keep-alive messages on the connection.
158158
func (c *TCPConn) SetKeepAlive(keepalive bool) error {
159159
if !c.ok() {
160160
return syscall.EINVAL
@@ -165,7 +165,7 @@ func (c *TCPConn) SetKeepAlive(keepalive bool) error {
165165
return nil
166166
}
167167

168-
// SetKeepAlivePeriod sets period between keep alives.
168+
// SetKeepAlivePeriod sets period between keep-alives.
169169
func (c *TCPConn) SetKeepAlivePeriod(d time.Duration) error {
170170
if !c.ok() {
171171
return syscall.EINVAL

0 commit comments

Comments
 (0)