No errors were logged when a service has no listeners

The starting of a service without listeners would fail but there wouldn't be
any log messages about the reason of the failure. In addition to this, MaxScale
would try to restart the service periodically which would lead to unnecessary
error messages.

With this change, missing listeners for services are considered configuration
errors.
This commit is contained in:
Markus Makela 2016-03-03 15:57:08 +02:00
parent 0ddb81ea16
commit cb8ea84853
3 changed files with 32 additions and 1 deletions

View File

@ -570,9 +570,14 @@ process_config_context(CONFIG_CONTEXT *context)
* error_count += consistency_checks();
*/
if (!service_all_services_have_listeners())
{
error_count++;
}
if (error_count)
{
MXS_ERROR("%d errors where encountered processing the configuration "
MXS_ERROR("%d errors were encountered while processing the configuration "
"file '%s'.", error_count, config_file);
return 0;
}

View File

@ -2249,3 +2249,28 @@ static void service_internal_restart(void *data)
SERVICE* service = (SERVICE*)data;
serviceStartAllPorts(service);
}
/**
* Check that all services have listeners
* @return True if all services have listeners
*/
bool service_all_services_have_listeners()
{
bool rval = true;
spinlock_acquire(&service_spin);
SERVICE* service = allServices;
while (service)
{
if (service->ports == NULL)
{
MXS_ERROR("Service '%s' has no listeners.", service->name);
rval = false;
}
service = service->next;
}
spinlock_release(&service_spin);
return rval;
}

View File

@ -264,5 +264,6 @@ extern void service_shutdown();
extern int serviceSessionCountAll();
extern RESULTSET *serviceGetList();
extern RESULTSET *serviceGetListenerList();
extern bool service_all_services_have_listeners();
#endif