Skip to content

Commit

Permalink
use Control instead of ControlContext
Browse files Browse the repository at this point in the history
  • Loading branch information
easwars committed Dec 6, 2023
1 parent 4a78dcb commit 2510f50
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
4 changes: 2 additions & 2 deletions dialoptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,8 @@ func WithTimeout(d time.Duration) DialOption {
// defaults for TCP keepalive time and interval to 15s. To enable TCP keepalive
// with OS defaults for keepalive time and interval, use a net.Dialer that sets
// the KeepAlive field to a negative value, and sets the SO_KEEPALIVE socket
// option to true from the Control or ControlContext field. For a concrete
// example of how to do this, see internal.NetDialerWithTCPKeepalive().
// option to true from the Control field. For a concrete example of how to do
// this, see internal.NetDialerWithTCPKeepalive().
//
// For more information, please see [issue 23459] in the Go github repo.
//
Expand Down
3 changes: 1 addition & 2 deletions internal/tcp_keepalive.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package internal

import (
"context"
"net"
"syscall"
"time"
Expand All @@ -42,7 +41,7 @@ func NetDialerWithTCPKeepalive() *net.Dialer {
// disabling the overriding of TCP keepalive parameters by setting the
// KeepAlive field to a negative value above, results in OS defaults for
// the TCP keealive interval and time parameters.
ControlContext: func(_ context.Context, _, _ string, c syscall.RawConn) error {
Control: func(_, _ string, c syscall.RawConn) error {
return c.Control(func(fd uintptr) {
syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_KEEPALIVE, 1)
})
Expand Down

0 comments on commit 2510f50

Please sign in to comment.