From 99b04920189df06cfd8704a773c51cdb995b7ae0 Mon Sep 17 00:00:00 2001 From: Vijay Bellur Date: Fri, 8 Oct 2010 04:54:36 +0000 Subject: support for configuring keepalive idle time Signed-off-by: Vijay Bellur Signed-off-by: Vijay Bellur BUG: 1802 (Gluster volume creation failed) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1802 --- doc/glusterd.vol | 2 ++ rpc/rpc-transport/socket/src/socket.c | 21 ++++++++++++++++----- rpc/rpc-transport/socket/src/socket.h | 1 + 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/doc/glusterd.vol b/doc/glusterd.vol index 48cad9579..b96cbe8ea 100644 --- a/doc/glusterd.vol +++ b/doc/glusterd.vol @@ -4,6 +4,8 @@ volume management option transport-type socket,rdma option transport.socket.listen-port 6969 option transport.rdma.listen-port 6968 + option transport.socket.keepalive-time 10 + option transport.socket.keepalive-interval 2 # option listen-port 6969 end-volume diff --git a/rpc/rpc-transport/socket/src/socket.c b/rpc/rpc-transport/socket/src/socket.c index c5246822a..341c8e94a 100644 --- a/rpc/rpc-transport/socket/src/socket.c +++ b/rpc/rpc-transport/socket/src/socket.c @@ -363,7 +363,7 @@ __socket_nodelay (int fd) static int -__socket_keepalive (int fd, int keepalive_intvl) +__socket_keepalive (int fd, int keepalive_intvl, int keepalive_idle) { int on = 1; int ret = -1; @@ -381,7 +381,7 @@ __socket_keepalive (int fd, int keepalive_intvl) if (ret == -1) goto err; #else - ret = setsockopt (fd, IPPROTO_TCP, TCP_KEEPIDLE, &keepalive_intvl, + ret = setsockopt (fd, IPPROTO_TCP, TCP_KEEPIDLE, &keepalive_idle, sizeof (keepalive_intvl)); if (ret == -1) goto err; @@ -394,7 +394,7 @@ __socket_keepalive (int fd, int keepalive_intvl) done: gf_log ("", GF_LOG_TRACE, "Keep-alive enabled for socket %d, interval " - "%d", fd, keepalive_intvl); + "%d, idle: %d", fd, keepalive_intvl, keepalive_idle); err: return ret; @@ -1802,7 +1802,8 @@ socket_server_event_handler (int fd, int idx, void *data, if (priv->keepalive) { ret = __socket_keepalive (new_sock, - priv->keepaliveintvl); + priv->keepaliveintvl, + priv->keepaliveidle); if (ret == -1) gf_log (this->name, GF_LOG_ERROR, "Failed to set keep-alive: %s", @@ -2010,7 +2011,8 @@ socket_connect (rpc_transport_t *this, int port) if (priv->keepalive) { ret = __socket_keepalive (priv->sock, - priv->keepaliveintvl); + priv->keepaliveintvl, + priv->keepaliveidle); if (ret == -1) gf_log (this->name, GF_LOG_ERROR, "Failed to set keep-alive: %s", @@ -2600,6 +2602,12 @@ socket_init (rpc_transport_t *this) priv->keepaliveintvl = keepalive; } + if (dict_get_uint32 (this->options, + "transport.socket.keepalive-time", + &keepalive) == 0) { + priv->keepaliveidle = keepalive; + } + priv->windowsize = (int)windowsize; out: this->private = priv; @@ -2699,5 +2707,8 @@ struct volume_options options[] = { { .key = {"transport.socket.keepalive-interval"}, .type = GF_OPTION_TYPE_INT }, + { .key = {"transport.socket.keepalive-time"}, + .type = GF_OPTION_TYPE_INT + }, { .key = {NULL} } }; diff --git a/rpc/rpc-transport/socket/src/socket.h b/rpc/rpc-transport/socket/src/socket.h index f7471ffb8..f54b64c2a 100644 --- a/rpc/rpc-transport/socket/src/socket.h +++ b/rpc/rpc-transport/socket/src/socket.h @@ -189,6 +189,7 @@ typedef struct { char lowlat; char nodelay; int keepalive; + int keepaliveidle; int keepaliveintvl; } socket_private_t; -- cgit