summaryrefslogtreecommitdiffstats
path: root/xlators/protocol
diff options
context:
space:
mode:
authorCsaba Henk <csaba@gluster.com>2010-05-24 09:32:56 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-05-26 00:26:02 -0700
commit5e849ce81a060a543201c431c5ba00e413cfdfff (patch)
treeddec2f88a64c367ee6d3ca0067e55301cd616158 /xlators/protocol
parentdda7eb5ff4d38cc0f280aa0e828da46e6d97195b (diff)
socket: make tcp keepalive work on OS X
Signed-off-by: Csaba Henk <csaba@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 754 (enable tcp keepalive) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=754
Diffstat (limited to 'xlators/protocol')
-rw-r--r--xlators/protocol/transport/socket/src/socket.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/xlators/protocol/transport/socket/src/socket.c b/xlators/protocol/transport/socket/src/socket.c
index 9ce5059e8..c5c019c48 100644
--- a/xlators/protocol/transport/socket/src/socket.c
+++ b/xlators/protocol/transport/socket/src/socket.c
@@ -259,15 +259,23 @@ __socket_keepalive (int fd, int keepalive_intvl)
if (keepalive_intvl == GF_USE_DEFAULT_KEEPALIVE)
goto done;
- ret = setsockopt (fd, SOL_TCP, TCP_KEEPIDLE, &keepalive_intvl,
+#ifdef GF_DARWIN_HOST_OS
+ ret = setsockopt (fd, IPPROTO_TCP, TCP_KEEPALIVE, &keepalive_intvl,
+ sizeof (keepalive_intvl));
+ if (ret == -1)
+ goto err;
+#else
+ ret = setsockopt (fd, IPPROTO_TCP, TCP_KEEPIDLE, &keepalive_intvl,
sizeof (keepalive_intvl));
if (ret == -1)
goto err;
- ret = setsockopt (fd, SOL_TCP, TCP_KEEPINTVL, &keepalive_intvl,
+ ret = setsockopt (fd, IPPROTO_TCP, TCP_KEEPINTVL, &keepalive_intvl,
sizeof (keepalive_intvl));
if (ret == -1)
goto err;
+#endif
+
done:
gf_log ("", GF_LOG_TRACE, "Keep-alive enabled for socket %d, interval "
"%d", fd, keepalive_intvl);