From ea752ed12b1e02cf9d70f2d9cade515c91ec2534 Mon Sep 17 00:00:00 2001 From: Shelikhoo Date: Sat, 20 Nov 2021 16:46:23 +0000 Subject: [PATCH] embed macOS const to avoid platform inconsistency --- transport/internet/sockopt_darwin.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/transport/internet/sockopt_darwin.go b/transport/internet/sockopt_darwin.go index a90a9815c..308616d1a 100644 --- a/transport/internet/sockopt_darwin.go +++ b/transport/internet/sockopt_darwin.go @@ -10,7 +10,8 @@ const ( // TCP_FASTOPEN_SERVER is the value to enable TCP fast open on darwin for server connections. TCP_FASTOPEN_SERVER = 0x01 // nolint: golint,stylecheck // TCP_FASTOPEN_CLIENT is the value to enable TCP fast open on darwin for client connections. - TCP_FASTOPEN_CLIENT = 0x02 // nolint: golint,stylecheck + TCP_FASTOPEN_CLIENT = 0x02 // nolint: revive,stylecheck + TCP_KEEPINTVL = 0x101 // nolint: golint,stylecheck ) func applyOutboundSocketOptions(network string, address string, fd uintptr, config *SocketConfig) error { @@ -52,7 +53,7 @@ func applyInboundSocketOptions(network string, fd uintptr, config *SocketConfig) } } if config.TcpKeepAliveInterval > 0 { - if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, syscall.TCP_KEEPINTVL, int(config.TcpKeepAliveInterval)); err != nil { + if err := syscall.SetsockoptInt(int(fd), syscall.IPPROTO_TCP, TCP_KEEPINTVL, int(config.TcpKeepAliveInterval)); err != nil { return newError("failed to set TCP_KEEPINTVL", err) } if err := syscall.SetsockoptInt(int(fd), syscall.SOL_SOCKET, syscall.SO_KEEPALIVE, 1); err != nil {