summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/client/src/client.c
diff options
context:
space:
mode:
authorMohammed Junaid <junaid@redhat.com>2012-03-09 12:44:05 +0530
committerVijay Bellur <vijay@gluster.com>2012-03-10 05:27:56 -0800
commitef108d4fa77fd9aba48a7b9475c9b72352c16e6a (patch)
treedf1f43943d5341ff6d2e0797de7b13e2599a68dd /xlators/protocol/client/src/client.c
parent56ec59a465c4a4a34bac3a785964c2517570898b (diff)
protocol/client: Register a timer(grace-timer) conditionally.
A grace timer is registered on a disconnect, but a reconnect timer sends a connect request after every 3sec and if the server is down, the client protocol receives disconnect and a grace timer will be registered which on timeout will increase the lk-version value. Its enough to register the grace timer once after the disconnect and later just ignore other psuedo disconnects. Change-Id: I36a153aa86b350d87fe50d014ee0297f558a7fb6 BUG: 795386 Signed-off-by: Mohammed Junaid <junaid@redhat.com> Reviewed-on: http://review.gluster.com/2906 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Amar Tumballi <amarts@redhat.com> Reviewed-by: Vijay Bellur <vijay@gluster.com>
Diffstat (limited to 'xlators/protocol/client/src/client.c')
-rw-r--r--xlators/protocol/client/src/client.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c
index b954906c1ce..3567dedbd1b 100644
--- a/xlators/protocol/client/src/client.c
+++ b/xlators/protocol/client/src/client.c
@@ -1985,13 +1985,16 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
/* Cancel grace timer if set */
pthread_mutex_lock (&conf->lock);
{
+ conf->grace_timer_flag = _gf_true;
+
if (conf->grace_timer) {
gf_log (this->name, GF_LOG_WARNING,
"Cancelling the grace timer");
gf_timer_call_cancel (this->ctx,
conf->grace_timer);
- conf->grace_timer = NULL;
+
+ conf->grace_timer = NULL;
}
}
pthread_mutex_unlock (&conf->lock);
@@ -2003,12 +2006,16 @@ client_rpc_notify (struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event,
pthread_mutex_lock (&conf->lock);
{
- if (conf->grace_timer) {
- gf_log (this->name, GF_LOG_DEBUG,
- "Client grace timer is already set");
+ if (conf->grace_timer || !conf->grace_timer_flag) {
+ gf_log (this->name, GF_LOG_TRACE,
+ "Client grace timer is already set "
+ "or a grace-timer has already timeout, "
+ "not registering a new timer");
} else {
gf_log (this->name, GF_LOG_WARNING,
"Registering a grace timer");
+ conf->grace_timer_flag = _gf_false;
+
conf->grace_timer =
gf_timer_call_after (this->ctx,
conf->grace_tv,
@@ -2322,7 +2329,6 @@ init (xlator_t *this)
int ret = -1;
clnt_conf_t *conf = NULL;
- /* */
if (this->children) {
gf_log (this->name, GF_LOG_ERROR,
"FATAL: client protocol translator cannot have any "
@@ -2343,8 +2349,9 @@ init (xlator_t *this)
INIT_LIST_HEAD (&conf->saved_fds);
/* Initialize parameters for lock self healing*/
- conf->lk_version = 1;
- conf->grace_timer = NULL;
+ conf->lk_version = 1;
+ conf->grace_timer = NULL;
+ conf->grace_timer_flag = _gf_true;
ret = client_init_grace_timer (this, this->options, conf);
if (ret)