MXS-1689 Add better error messages

If a listener section specifies both a 'socket' and a 'port' the
creation will fail with a clear error message.

If 'address' and 'socket' is specified, there will be a warning that
the address is meaningless.
This commit is contained in:
Johan Wikman
2018-03-07 13:16:26 +02:00
parent 7ae3931511
commit 5f328bc017

View File

@ -3448,6 +3448,15 @@ int create_new_listener(CONFIG_CONTEXT *obj)
char *authenticator_options = config_get_value(obj->parameters, CN_AUTHENTICATOR_OPTIONS);
if (raw_service_name && protocol && (socket || port))
{
if (socket && port)
{
MXS_ERROR("Creation of listener '%s' for service '%s' failed, because "
"both 'socket' and 'port' are defined. Only either one is allowed.",
obj->object, raw_service_name);
error_count++;
}
else
{
char service_name[strlen(raw_service_name) + 1];
strcpy(service_name, raw_service_name);
@ -3460,6 +3469,14 @@ int create_new_listener(CONFIG_CONTEXT *obj)
SSL_LISTENER *ssl_info = make_ssl_structure(obj, true, &error_count);
if (socket)
{
if (address)
{
MXS_WARNING("In the definition of the listener `%s', the value of "
"'address' lacks meaning as the listener listens on a "
"domain socket ('%s') and not on a port.",
obj->object, socket);
}
listener = service_find_listener(service, socket, NULL, 0);
if (listener)
@ -3506,10 +3523,11 @@ int create_new_listener(CONFIG_CONTEXT *obj)
error_count++;
}
}
}
else
{
MXS_ERROR("Listener '%s' is missing a required parameter. A Listener "
"must have a service, port and protocol defined.", obj->object);
"must have a service, protocol and port (or socket) defined.", obj->object);
error_count++;
}