summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/client/src
diff options
context:
space:
mode:
authorAnoop C S <anoopcs@redhat.com>2015-08-15 10:38:00 +0530
committerJeff Darcy <jdarcy@redhat.com>2015-09-03 08:18:33 -0700
commitb5fff7326e9203c650eb5d395bc5a338075821f1 (patch)
tree2c281e71323b594a86ea665a1bcd4b13bf56a6b9 /xlators/protocol/client/src
parentfe7b37960bbef791d9bed79760b61b1d40ca81cd (diff)
protocol-client/server: Fix incorrect grace-timeout value in logs
When grace-timer is initialized via server/client init, the default or reconfigured value for grace-timeout is displayed incorrectly in both server and client logs. This is because we use gf_time_fmt() to format this grace-timeout value with gf_timefmt_s as the time format as shown below: gf_time_fmt (timestr, sizeof timestr, conf->grace_ts.tv_sec, gf_timefmt_s); gf_timefmt_s format is a wrapper for %s format specification used in strftime library call which populates the number of seconds since the Epoch [1970-01-01 00:00:00 +0000 (UTC)]. But this particular format is dependent on timezone [1970-01-01 05:30:00 +0530 (IST)]and thus displayed incorrectly in logs. Example: For IST with default grace-timeout value 10, it is displayed as -19790 which is calculated as follows, 1970-01-01 00:00:10 - 1970-01-01 05:30:00 = -19790 seconds. Change-Id: I1bdf5d12b2167323f86f0ca52a37ffb316b3f0a2 BUG: 1227667 Signed-off-by: Anoop C S <anoopcs@redhat.com> Reviewed-on: http://review.gluster.org/11930 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Reviewed-by: Raghavendra Talur <rtalur@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Jeff Darcy <jdarcy@redhat.com>
Diffstat (limited to 'xlators/protocol/client/src')
-rw-r--r--xlators/protocol/client/src/client.c30
-rw-r--r--xlators/protocol/client/src/client.h2
2 files changed, 11 insertions, 21 deletions
diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c
index 0de738b6e67..4ce210bf364 100644
--- a/xlators/protocol/client/src/client.c
+++ b/xlators/protocol/client/src/client.c
@@ -177,10 +177,14 @@ int32_t
client_register_grace_timer (xlator_t *this, clnt_conf_t *conf)
{
int32_t ret = -1;
+ struct timespec grace_ts = {0, };
GF_VALIDATE_OR_GOTO ("client", this, out);
GF_VALIDATE_OR_GOTO (this->name, conf, out);
+ grace_ts.tv_sec = conf->grace_timeout;
+ grace_ts.tv_nsec = 0;
+
pthread_mutex_lock (&conf->lock);
{
if (conf->grace_timer || !conf->grace_timer_needed) {
@@ -196,7 +200,7 @@ client_register_grace_timer (xlator_t *this, clnt_conf_t *conf)
conf->grace_timer =
gf_timer_call_after (this->ctx,
- conf->grace_ts,
+ grace_ts,
client_grace_timeout,
conf->rpc);
}
@@ -2320,36 +2324,22 @@ int
client_init_grace_timer (xlator_t *this, dict_t *options,
clnt_conf_t *conf)
{
- char timestr[64] = {0,};
- char *lk_heal = NULL;
int32_t ret = -1;
- int32_t grace_timeout = -1;
GF_VALIDATE_OR_GOTO ("client", this, out);
GF_VALIDATE_OR_GOTO (this->name, options, out);
GF_VALIDATE_OR_GOTO (this->name, conf, out);
- conf->lk_heal = _gf_false;
-
- ret = dict_get_str (options, "lk-heal", &lk_heal);
- if (!ret)
- gf_string2boolean (lk_heal, &conf->lk_heal);
+ GF_OPTION_RECONF ("lk-heal", conf->lk_heal, options, bool, out);
gf_msg_debug (this->name, 0, "lk-heal = %s",
(conf->lk_heal) ? "on" : "off");
- ret = dict_get_int32 (options, "grace-timeout", &grace_timeout);
- if (!ret)
- conf->grace_ts.tv_sec = grace_timeout;
- else
- conf->grace_ts.tv_sec = 10;
-
- conf->grace_ts.tv_nsec = 0;
+ GF_OPTION_RECONF ("grace-timeout", conf->grace_timeout,
+ options, uint32, out);
- gf_time_fmt (timestr, sizeof timestr, conf->grace_ts.tv_sec,
- gf_timefmt_s);
- gf_msg_debug (this->name, 0, "Client grace timeout value = %s",
- timestr);
+ gf_msg_debug (this->name, 0, "Client grace timeout value = %d",
+ conf->grace_timeout);
ret = 0;
out:
diff --git a/xlators/protocol/client/src/client.h b/xlators/protocol/client/src/client.h
index 38f34d56fe7..55f95257a6d 100644
--- a/xlators/protocol/client/src/client.h
+++ b/xlators/protocol/client/src/client.h
@@ -104,7 +104,7 @@ typedef struct clnt_conf {
uint16_t lk_version; /* this variable is used to distinguish
client-server transaction while
performing lock healing */
- struct timespec grace_ts;
+ uint32_t grace_timeout;
gf_timer_t *grace_timer;
gf_boolean_t grace_timer_needed; /* The state of this flag will
be used to decide whether