summaryrefslogtreecommitdiffstats
path: root/rpc/rpc-lib/src/rpc-clnt.c
diff options
context:
space:
mode:
authorKrishnan Parthasarathi <kparthas@redhat.com>2014-04-07 10:57:45 +0530
committerAnand Avati <avati@redhat.com>2014-04-29 14:23:51 -0700
commitc61bc1f9e5874cb8380ec6398680fc71aea233b4 (patch)
treec02fee67ebcc7c43a6338d34c5700916e672c110 /rpc/rpc-lib/src/rpc-clnt.c
parent91ab65f812ec3b674f53230eacbd0d71964d3d01 (diff)
glusterd: Ping timer implmentation
This patch refactors the existing client ping timer implementation, and makes use of the common code for implementing both client ping timer and the glusterd ping timer. A new gluster rpc program for ping is introduced. The ping timer is only started for peers that have this new program. The deafult glusterd ping timeout is 30 seconds. It is configurable by setting the option 'ping-timeout' in glusterd.vol . Also, this patch introduces changes in the glusterd-handshake path. The client programs for a peer are now set in the callback of dump_versions, for both the older handshake and the newer op-version handshake. This is the only place in the handshake process where we know what programs a peer supports. Change-Id: I035815ac13449ca47080ecc3253c0a9afbe9016a BUG: 1038261 Signed-off-by: Vijaikumar M <vmallika@redhat.com> Signed-off-by: Krishnan Parthasarathi <kparthas@redhat.com> Reviewed-on: http://review.gluster.org/5202 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'rpc/rpc-lib/src/rpc-clnt.c')
-rw-r--r--rpc/rpc-lib/src/rpc-clnt.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/rpc/rpc-lib/src/rpc-clnt.c b/rpc/rpc-lib/src/rpc-clnt.c
index 3106342e970..46ee0eebcd0 100644
--- a/rpc/rpc-lib/src/rpc-clnt.c
+++ b/rpc/rpc-lib/src/rpc-clnt.c
@@ -17,6 +17,7 @@
#define RPC_CLNT_DEFAULT_REQUEST_COUNT 512
#include "rpc-clnt.h"
+#include "rpc-clnt-ping.h"
#include "byte-order.h"
#include "xdr-rpcclnt.h"
#include "rpc-transport.h"
@@ -552,6 +553,7 @@ rpc_clnt_connection_cleanup (rpc_clnt_connection_t *conn)
gf_timer_call_cancel (clnt->ctx, conn->ping_timer);
conn->ping_timer = NULL;
conn->ping_started = 0;
+ rpc_clnt_unref (clnt);
}
}
pthread_mutex_unlock (&conn->lock);
@@ -1000,6 +1002,17 @@ rpc_clnt_connection_init (struct rpc_clnt *clnt, glusterfs_ctx_t *ctx,
}
conn->rpc_clnt = clnt;
+ ret = dict_get_int32 (options, "ping-timeout",
+ &conn->ping_timeout);
+ if (ret >= 0) {
+ gf_log (name, GF_LOG_DEBUG,
+ "setting ping-timeout to %d", conn->ping_timeout);
+ } else {
+ gf_log (name, GF_LOG_INFO,
+ "defaulting ping-timeout to 30secs");
+ conn->ping_timeout = 30;
+ }
+
trans = rpc_transport_load (ctx, options, name);
if (!trans) {
gf_log (name, GF_LOG_WARNING, "loading of new rpc-transport"
@@ -1592,6 +1605,7 @@ rpc_clnt_submit (struct rpc_clnt *rpc, rpc_clnt_prog_t *prog,
goto out;
}
+ rpc_clnt_start_ping (rpc);
ret = 0;
out:
@@ -1734,6 +1748,7 @@ rpc_clnt_disable (struct rpc_clnt *rpc)
gf_timer_call_cancel (rpc->ctx, conn->ping_timer);
conn->ping_timer = NULL;
conn->ping_started = 0;
+ rpc_clnt_unref (rpc);
}
trans = conn->trans;
conn->trans = NULL;