From 5e849ce81a060a543201c431c5ba00e413cfdfff Mon Sep 17 00:00:00 2001 From: Csaba Henk Date: Mon, 24 May 2010 09:32:56 +0000 Subject: socket: make tcp keepalive work on OS X Signed-off-by: Csaba Henk Signed-off-by: Anand V. Avati BUG: 754 (enable tcp keepalive) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=754 --- xlators/protocol/transport/socket/src/socket.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'xlators/protocol') diff --git a/xlators/protocol/transport/socket/src/socket.c b/xlators/protocol/transport/socket/src/socket.c index 9ce5059e840..c5c019c4860 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); -- cgit