diff options
| author | Csaba Henk <csaba@gluster.com> | 2010-05-26 15:04:22 +0000 | 
|---|---|---|
| committer | Anand V. Avati <avati@dev.gluster.com> | 2010-05-27 02:00:56 -0700 | 
| commit | 1a6776395d77b359c4804d2494e1b30480782b6d (patch) | |
| tree | 99564998ceec8744a7fa6a8072366f65efb9f79d | |
| parent | 0d34328ba04c967192b31d60dfeb6cd164ae7119 (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
BUG: 754 (enable tcp keepalive)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=754
| -rw-r--r-- | transport/socket/src/socket.c | 12 | 
1 files changed, 10 insertions, 2 deletions
diff --git a/transport/socket/src/socket.c b/transport/socket/src/socket.c index 4d4b01b5c..d1c63353d 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);  | 
