From cb8ea848539f00a9440228aef1abf8fb3888e85f Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Thu, 3 Mar 2016 15:57:08 +0200 Subject: [PATCH] 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. --- server/core/config.c | 7 ++++++- server/core/service.c | 25 +++++++++++++++++++++++++ server/include/service.h | 1 + 3 files changed, 32 insertions(+), 1 deletion(-) diff --git a/server/core/config.c b/server/core/config.c index 79a185c3e..c5fbb4e5c 100644 --- a/server/core/config.c +++ b/server/core/config.c @@ -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; } diff --git a/server/core/service.c b/server/core/service.c index b741edc81..7eab44d50 100644 --- a/server/core/service.c +++ b/server/core/service.c @@ -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; +} diff --git a/server/include/service.h b/server/include/service.h index db9d76ad0..05ccf74ec 100644 --- a/server/include/service.h +++ b/server/include/service.h @@ -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