From 1a6776395d77b359c4804d2494e1b30480782b6d Mon Sep 17 00:00:00 2001 From: Csaba Henk Date: Wed, 26 May 2010 15:04:22 +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 BUG: 754 (enable tcp keepalive) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=754 --- transport/socket/src/socket.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'transport') diff --git a/transport/socket/src/socket.c b/transport/socket/src/socket.c index 4d4b01b5cf8..d1c63353dcd 100644 --- a/transport/socket/src/socket.c +++ b/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