summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--xlators/protocol/client/src/client.c30
-rw-r--r--xlators/protocol/client/src/client.h2
-rw-r--r--xlators/protocol/server/src/server.c31
-rw-r--r--xlators/protocol/server/src/server.h2
4 files changed, 23 insertions, 42 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
diff --git a/xlators/protocol/server/src/server.c b/xlators/protocol/server/src/server.c
index 93cf45d5904..a98b609da39 100644
--- a/xlators/protocol/server/src/server.c
+++ b/xlators/protocol/server/src/server.c
@@ -487,6 +487,7 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event,
server_conf_t *conf = NULL;
client_t *client = NULL;
server_ctx_t *serv_ctx = NULL;
+ struct timespec grace_ts = {0, };
if (!xl || !data) {
gf_msg_callingfn ("server", GF_LOG_WARNING, 0,
@@ -569,6 +570,9 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event,
goto out;
}
+ grace_ts.tv_sec = conf->grace_timeout;
+ grace_ts.tv_nsec = 0;
+
LOCK (&serv_ctx->fdtable_lock);
{
if (!serv_ctx->grace_timer) {
@@ -580,7 +584,7 @@ server_rpc_notify (rpcsvc_t *rpc, void *xl, rpcsvc_event_t event,
serv_ctx->grace_timer =
gf_timer_call_after (this->ctx,
- conf->grace_ts,
+ grace_ts,
grace_time_handler,
client);
}
@@ -665,36 +669,22 @@ int
server_init_grace_timer (xlator_t *this, dict_t *options,
server_conf_t *conf)
{
- char timestr[64] = {0,};
int32_t ret = -1;
- int32_t grace_timeout = -1;
- char *lk_heal = NULL;
GF_VALIDATE_OR_GOTO ("server", 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;
-
- gf_time_fmt (timestr, sizeof timestr, conf->grace_ts.tv_sec,
- gf_timefmt_s);
- gf_msg_debug (this->name, 0, "Server grace timeout value = %s",
- timestr);
+ GF_OPTION_RECONF ("grace-timeout", conf->grace_timeout,
+ options, uint32, out);
- conf->grace_ts.tv_nsec = 0;
+ gf_msg_debug (this->name, 0, "Server grace timeout value = %d",
+ conf->grace_timeout);
ret = 0;
out:
@@ -1339,6 +1329,7 @@ struct volume_options options[] = {
.type = GF_OPTION_TYPE_INT,
.min = 10,
.max = 1800,
+ .default_value = "10",
},
{.key = {"tcp-window-size"},
.type = GF_OPTION_TYPE_SIZET,
diff --git a/xlators/protocol/server/src/server.h b/xlators/protocol/server/src/server.h
index 1055b72dad5..dd80ab75f60 100644
--- a/xlators/protocol/server/src/server.h
+++ b/xlators/protocol/server/src/server.h
@@ -54,7 +54,7 @@ struct server_conf {
heal is on else off. */
char *conf_dir;
struct _volfile_ctx *volfile;
- struct timespec grace_ts;
+ uint32_t grace_timeout;
dict_t *auth_modules;
pthread_mutex_t mutex;
struct list_head xprt_list;