From 6b74f3ec7b6e0fed2e253df456b067fc27049117 Mon Sep 17 00:00:00 2001 From: Kaushik BV Date: Tue, 5 Oct 2010 07:02:07 +0000 Subject: Reply back to CLI on error, by validating each xlator's opts Signed-off-by: Kaushik BV Signed-off-by: Vijay Bellur BUG: 1159 () URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1159 --- xlators/protocol/client/src/client.c | 71 ++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) (limited to 'xlators/protocol/client/src/client.c') diff --git a/xlators/protocol/client/src/client.c b/xlators/protocol/client/src/client.c index 5cf3b1ea19f..50cb917aacc 100644 --- a/xlators/protocol/client/src/client.c +++ b/xlators/protocol/client/src/client.c @@ -1781,6 +1781,77 @@ out: return ret; } +int +validate_options (xlator_t *this, dict_t *options, char **op_errstr) +{ + int ret = 0; + int timeout_ret=0; + int ping_timeout; + int frame_timeout; + + + timeout_ret = dict_get_int32 (options, "frame-timeout", + &frame_timeout); + if (timeout_ret == 0) { + if (frame_timeout < 5 ) { + gf_log (this->name, GF_LOG_WARNING, "Validation" + "'option frame-timeout %d failed , Min value" + " can be 5", frame_timeout); + *op_errstr = gf_strdup ("Error, Min Value 5"); + ret = -1; + goto out; + } + + if (frame_timeout > 86400 ) { + gf_log (this->name, GF_LOG_WARNING, "Reconfiguration" + "'option frame-timeout %d failed , Max value" + "can be 86400", frame_timeout ); + *op_errstr = gf_strdup ("Error, Max Value 86400"); + ret = -1; + goto out; + } + + + gf_log (this->name, GF_LOG_DEBUG, + "validation otion frame-timeout to %d", + frame_timeout); + + } + + timeout_ret = dict_get_int32 (options, "ping-timeout", + &ping_timeout); + if (timeout_ret == 0) { + + if (ping_timeout < 5 ) { + gf_log (this->name, GF_LOG_WARNING, "Reconfiguration" + "'option ping-timeout %d failed , Min value" + " can be 5", ping_timeout); + *op_errstr = gf_strdup ("Error, Min Value 5"); + ret = -1; + goto out; + } + + if (ping_timeout > 1013 ) { + gf_log (this->name, GF_LOG_WARNING, "Reconfiguration" + "'option frame-timeout %d failed , Max value" + "can be 1013,", frame_timeout); + *op_errstr = gf_strdup ("Error, Max Value 1013"); + ret = -1; + goto out; + } + + gf_log (this->name, GF_LOG_DEBUG, "Validated " + "'option ping-timeout' to %d", ping_timeout); + + } + + ret = 0; + +out: + return ret; + +} + int reconfigure (xlator_t *this, dict_t *options) { -- cgit