This is an automated email from the ASF dual-hosted git repository.

alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git


The following commit(s) were added to refs/heads/master by this push:
     new a69d9b197 [util] make Socket::SetTcpKeepAlive() available on macOS
a69d9b197 is described below

commit a69d9b197a4ef1290e6931a75bd28257d949b315
Author: Alexey Serbin <ale...@apache.org>
AuthorDate: Fri Dec 8 18:04:10 2023 -0800

    [util] make Socket::SetTcpKeepAlive() available on macOS
    
    Change-Id: I52c6e48181480415fc5ebc1b804aa21d0491b584
    Reviewed-on: http://gerrit.cloudera.org:8080/20765
    Tested-by: Alexey Serbin <ale...@apache.org>
    Reviewed-by: Mahesh Reddy <mre...@cloudera.com>
    Reviewed-by: Abhishek Chennaka <achenn...@cloudera.com>
---
 src/kudu/util/net/socket.cc | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/kudu/util/net/socket.cc b/src/kudu/util/net/socket.cc
index 427429688..1ce2da66d 100644
--- a/src/kudu/util/net/socket.cc
+++ b/src/kudu/util/net/socket.cc
@@ -591,11 +591,15 @@ Status Socket::SetTimeout(int opt, const char* optname, 
const MonoDelta& timeout
 }
 
 Status Socket::SetTcpKeepAlive(int idle_time_s, int retry_time_s, int 
num_retries) {
-#if defined(__linux__)
   static const char* const err_string = "failed to set socket option $0 to $1";
   DCHECK_GT(idle_time_s, 0);
+#if defined(__linux__)
   RETURN_NOT_OK_PREPEND(SetSockOpt(IPPROTO_TCP, TCP_KEEPIDLE, idle_time_s),
       Substitute(err_string, "TCP_KEEPIDLE", idle_time_s));
+#else
+  RETURN_NOT_OK_PREPEND(SetSockOpt(IPPROTO_TCP, TCP_KEEPALIVE, idle_time_s),
+      Substitute(err_string, "TCP_KEEPALIVE", idle_time_s));
+#endif
   DCHECK_GT(retry_time_s, 0);
   RETURN_NOT_OK_PREPEND(SetSockOpt(IPPROTO_TCP, TCP_KEEPINTVL, retry_time_s),
       Substitute(err_string, "TCP_KEEPINTVL", retry_time_s));
@@ -604,7 +608,6 @@ Status Socket::SetTcpKeepAlive(int idle_time_s, int 
retry_time_s, int num_retrie
       Substitute(err_string, "TCP_KEEPCNT", num_retries));
   RETURN_NOT_OK_PREPEND(SetSockOpt(SOL_SOCKET, SO_KEEPALIVE, 1),
       "failed to enable TCP KeepAlive socket option");
-#endif
   return Status::OK();
 }
 

Reply via email to