diff --git a/server/core/config.c b/server/core/config.c index 7958cb175..31c550b9a 100644 --- a/server/core/config.c +++ b/server/core/config.c @@ -2824,12 +2824,6 @@ int configure_new_service(CONFIG_CONTEXT *context, CONFIG_CONTEXT *obj) s = strtok_r(NULL, ",", &lasts); } } - else if (servers == NULL && !is_internal_service(router)) - { - MXS_ERROR("The service '%s' is missing a definition of the servers " - "that provide the service.", obj->object); - error_count++; - } if (roptions) { @@ -2882,12 +2876,6 @@ int create_new_monitor(CONFIG_CONTEXT *context, CONFIG_CONTEXT *obj, HASHTABLE* } char *servers = config_get_value(obj->parameters, "servers"); - if (servers == NULL) - { - MXS_ERROR("Monitor '%s' is missing the 'servers' parameter that " - "lists the servers that it monitors.", obj->object); - error_count++; - } if (error_count == 0) { @@ -2934,36 +2922,39 @@ int create_new_monitor(CONFIG_CONTEXT *context, CONFIG_CONTEXT *obj, HASHTABLE* } } - /* get the servers to monitor */ - char *s, *lasts; - s = strtok_r(servers, ",", &lasts); - while (s) + if (servers) { - CONFIG_CONTEXT *obj1 = context; - int found = 0; - while (obj1) + /* get the servers to monitor */ + char *s, *lasts; + s = strtok_r(servers, ",", &lasts); + while (s) { - if (strcmp(trim(s), obj1->object) == 0 && obj->element && obj1->element) + CONFIG_CONTEXT *obj1 = context; + int found = 0; + while (obj1) { - found = 1; - if (hashtable_add(monitorhash, obj1->object, "") == 0) + if (strcmp(trim(s), obj1->object) == 0 && obj->element && obj1->element) { - MXS_WARNING("Multiple monitors are monitoring server [%s]. " - "This will cause undefined behavior.", - obj1->object); + found = 1; + if (hashtable_add(monitorhash, obj1->object, "") == 0) + { + MXS_WARNING("Multiple monitors are monitoring server [%s]. " + "This will cause undefined behavior.", + obj1->object); + } + monitorAddServer(obj->element, obj1->element); } - monitorAddServer(obj->element, obj1->element); + obj1 = obj1->next; + } + if (!found) + { + MXS_ERROR("Unable to find server '%s' that is " + "configured in the monitor '%s'.", s, obj->object); + error_count++; } - obj1 = obj1->next; - } - if (!found) - { - MXS_ERROR("Unable to find server '%s' that is " - "configured in the monitor '%s'.", s, obj->object); - error_count++; - } - s = strtok_r(NULL, ",", &lasts); + s = strtok_r(NULL, ",", &lasts); + } } char *user = config_get_value(obj->parameters, "user"); diff --git a/server/core/monitor.c b/server/core/monitor.c index b67e6ecf4..d1d2a8d88 100644 --- a/server/core/monitor.c +++ b/server/core/monitor.c @@ -58,7 +58,7 @@ const monitor_def_t monitor_event_definitions[MAX_MONITOR_EVENT] = static MONITOR *allMonitors = NULL; static SPINLOCK monLock = SPINLOCK_INIT; -static void monitor_servers_free(MONITOR_SERVERS *servers); +static void monitor_server_free_all(MONITOR_SERVERS *servers); /** * Allocate a new monitor, load the associated module for the monitor @@ -142,7 +142,7 @@ monitor_free(MONITOR *mon) } spinlock_release(&monLock); free_config_parameter(mon->parameters); - monitor_servers_free(mon->databases); + monitor_server_free_all(mon->databases); MXS_FREE(mon->name); MXS_FREE(mon); } @@ -304,7 +304,7 @@ static void monitor_server_free(MONITOR_SERVERS *tofree) * Free monitor server list * @param servers Servers to free */ -static void monitor_servers_free(MONITOR_SERVERS *servers) +static void monitor_server_free_all(MONITOR_SERVERS *servers) { while (servers) { @@ -357,7 +357,7 @@ void monitorRemoveServer(MONITOR *mon, SERVER *server) if (ptr) { - monitor_servers_free(ptr); + monitor_server_free(ptr); } if (old_state == MONITOR_STATE_RUNNING) @@ -608,13 +608,8 @@ monitorGetList() */ bool check_monitor_permissions(MONITOR* monitor, const char* query) { - if (monitor->databases == NULL) - { - MXS_ERROR("[%s] Monitor is missing the servers parameter.", monitor->name); - return false; - } - - if (config_get_global_options()->skip_permission_checks) + if (monitor->databases == NULL || // No servers to check + config_get_global_options()->skip_permission_checks) { return true; } diff --git a/server/core/service.c b/server/core/service.c index aef3b022d..c2196ac51 100644 --- a/server/core/service.c +++ b/server/core/service.c @@ -821,13 +821,12 @@ void serviceRemoveBackend(SERVICE *service, const SERVER *server) { spinlock_acquire(&service->spin); - service->n_dbref--; - for (SERVER_REF *ref = service->dbref; ref; ref = ref->next) { if (ref->server == server) { ref->active = false; + service->n_dbref--; break; } } diff --git a/server/modules/authenticator/MySQLAuth/dbusers.c b/server/modules/authenticator/MySQLAuth/dbusers.c index ec4cbad6f..d08a0d40a 100644 --- a/server/modules/authenticator/MySQLAuth/dbusers.c +++ b/server/modules/authenticator/MySQLAuth/dbusers.c @@ -2649,17 +2649,12 @@ static bool check_server_permissions(SERVICE *service, SERVER* server, bool check_service_permissions(SERVICE* service) { if (is_internal_service(service->routerModule) || - config_get_global_options()->skip_permission_checks) + config_get_global_options()->skip_permission_checks || + service->dbref == NULL) // No servers to check { return true; } - if (service->dbref == NULL) - { - MXS_ERROR("[%s] Service is missing the servers parameter.", service->name); - return false; - } - char *user, *password; if (serviceGetUser(service, &user, &password) == 0) diff --git a/server/modules/monitor/mysqlmon/mysql_mon.c b/server/modules/monitor/mysqlmon/mysql_mon.c index 86967962d..cc2b425df 100644 --- a/server/modules/monitor/mysqlmon/mysql_mon.c +++ b/server/modules/monitor/mysqlmon/mysql_mon.c @@ -215,7 +215,7 @@ bool init_server_info(MYSQL_MONITOR *handle, MONITOR_SERVERS *database) while (database) { /** Delete any existing structures and replace them with empty ones */ - hashtable_delete(handle->server_info, database->server); + hashtable_delete(handle->server_info, database->server->unique_name); if (!hashtable_add(handle->server_info, database->server->unique_name, &info)) {