MXS-1851: Add hard-coded protocol module check

This way a hard to track crash is avoided and the user knows how to fix
it.
This commit is contained in:
Markus Mäkelä 2019-05-23 15:38:10 +03:00
parent a1697e2aa6
commit eda547c86f
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19

View File

@ -3066,6 +3066,15 @@ const char* param_type_to_str(const MXS_MODULE_PARAM* params, const char* name)
return "<unknown parameter name>";
}
static bool wrong_protocol_type(const std::string& type, const std::string& protocol)
{
bool have_server_proto = strcasecmp(protocol.c_str(), "mariadbbackend") == 0
|| strcasecmp(protocol.c_str(), "mysqlbackend") == 0;
bool have_server_type = type == CN_SERVER;
return have_server_proto != have_server_type;
}
/**
* @brief Check that the configuration objects have valid parameters
*
@ -3111,6 +3120,14 @@ static bool check_config_objects(CONFIG_CONTEXT* context)
continue;
}
// TODO: Separate the listener and server protocol objects, hard-coded checks are not good
if (wrong_protocol_type(type, config_get_string(obj->parameters, CN_PROTOCOL)))
{
MXS_ERROR("Wrong protocol module type for '%s'", obj->object);
rval = false;
continue;
}
mxb_assert(param_set);
std::vector<std::string> to_be_removed;