diff --git a/include/maxscale/modinfo.h b/include/maxscale/modinfo.h index 4dafa1a68..710638c7e 100644 --- a/include/maxscale/modinfo.h +++ b/include/maxscale/modinfo.h @@ -109,6 +109,7 @@ enum mxs_module_param_options MXS_MODULE_OPT_PATH_F_OK = (1 << 4), /**< PATH: Path must exist */ MXS_MODULE_OPT_PATH_CREAT = (1 << 5), /**< PATH: Create path if it doesn't exist */ MXS_MODULE_OPT_ENUM_UNIQUE = (1 << 6), /**< ENUM: Only one value can be defined */ + MXS_MODULE_OPT_DURATION_S = (1 << 7), /**< DURATION: Cannot be specified in milliseconds */ /**< Parameter is deprecated: Causes a warning to be logged if the parameter * is used but will not cause a configuration error. */ diff --git a/server/core/config.cc b/server/core/config.cc index ea9b3d24a..d84e30277 100644 --- a/server/core/config.cc +++ b/server/core/config.cc @@ -4484,13 +4484,27 @@ bool config_param_is_valid(const MXS_MODULE_PARAM* params, { valid = true; - if (unit == mxs::config::DURATION_IN_DEFAULT) + switch (unit) { + case mxs::config::DURATION_IN_MILLISECONDS: + if (params[i].options & MXS_MODULE_OPT_DURATION_S) + { + MXS_ERROR("Currently the granularity of '%s' is seconds. The value " + "cannot be specified in milliseconds.", params[i].name); + valid = false; + } + break; + + case mxs::config::DURATION_IN_DEFAULT: MXS_WARNING("Specifying durations without a suffix denoting the unit " "has been deprecated: '%s=%s'. Use the suffixes 'h' (hour), " "'m' (minute) 's' (second) or 'ms' (milliseconds). " "For instance, '%s=%ss' or '%s=%sms.", key, value, key, value, key, value); + break; + + default: + break; } } } diff --git a/server/core/test/test_config.cc b/server/core/test/test_config.cc index 206684279..eaf457522 100644 --- a/server/core/test/test_config.cc +++ b/server/core/test/test_config.cc @@ -44,6 +44,7 @@ int test_validity() {"p7", MXS_MODULE_PARAM_SERVICE, "my-service" }, {"p8", MXS_MODULE_PARAM_ENUM, "a", MXS_MODULE_OPT_ENUM_UNIQUE, enum_values}, {"p9", MXS_MODULE_PARAM_DURATION, "4711s" }, + {"p10", MXS_MODULE_PARAM_DURATION, "4711s", MXS_MODULE_OPT_DURATION_S }, {MXS_END_MODULE_PARAMS} }; @@ -107,6 +108,7 @@ int test_validity() TEST(config_param_is_valid(params, "p9", "4711S", &ctx)); TEST(config_param_is_valid(params, "p9", "4711MS", &ctx)); TEST(!config_param_is_valid(params, "p9", "4711q", &ctx)); + TEST(!config_param_is_valid(params, "p10", "4711ms", &ctx)); /** Service parameter */ CONFIG_CONTEXT svc("test-service");