MXS-2303: Fix missing parameter error
The detection of missing parameters that define which module to load must be done before the module is loaded.
This commit is contained in:
parent
6ab3985164
commit
3f4c72d4f2
@ -1291,6 +1291,34 @@ const MXS_MODULE* get_module(CONFIG_CONTEXT* obj, const char* param_name, const
|
||||
return module ? get_module(module, module_type) : NULL;
|
||||
}
|
||||
|
||||
const char* get_missing_module_parameter_name(const CONFIG_CONTEXT* obj)
|
||||
{
|
||||
std::string type = config_get_string(obj->parameters, CN_TYPE);
|
||||
|
||||
if (type == CN_SERVICE && !config_get_param(obj->parameters, CN_ROUTER))
|
||||
{
|
||||
return CN_ROUTER;
|
||||
}
|
||||
else if (type == CN_LISTENER && !config_get_param(obj->parameters, CN_PROTOCOL))
|
||||
{
|
||||
return CN_PROTOCOL;
|
||||
}
|
||||
else if (type == CN_SERVER && !config_get_param(obj->parameters, CN_PROTOCOL))
|
||||
{
|
||||
return CN_PROTOCOL;
|
||||
}
|
||||
else if (type == CN_MONITOR && !config_get_param(obj->parameters, CN_MODULE))
|
||||
{
|
||||
return CN_MODULE;
|
||||
}
|
||||
else if (type == CN_FILTER && !config_get_param(obj->parameters, CN_MODULE))
|
||||
{
|
||||
return CN_MODULE;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::pair<const MXS_MODULE_PARAM*, const MXS_MODULE*> get_module_details(const CONFIG_CONTEXT* obj)
|
||||
{
|
||||
std::string type = config_get_string(obj->parameters, CN_TYPE);
|
||||
@ -3044,6 +3072,15 @@ static bool check_config_objects(CONFIG_CONTEXT* context)
|
||||
continue;
|
||||
}
|
||||
|
||||
const char* no_module_defined = get_missing_module_parameter_name(obj);
|
||||
|
||||
if (no_module_defined)
|
||||
{
|
||||
MXS_ERROR("'%s' is missing the required parameter '%s'", obj->object, no_module_defined);
|
||||
rval = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
const MXS_MODULE_PARAM* param_set = nullptr;
|
||||
const MXS_MODULE* mod = nullptr;
|
||||
std::tie(param_set, mod) = get_module_details(obj);
|
||||
|
Loading…
x
Reference in New Issue
Block a user