diff --git a/examples/roundrobinrouter.cpp b/examples/roundrobinrouter.cpp index 38aa95285..fc761a807 100644 --- a/examples/roundrobinrouter.cpp +++ b/examples/roundrobinrouter.cpp @@ -162,11 +162,11 @@ RRRouter::RRRouter(SERVICE* service) { RR_DEBUG("Creating instance."); /* Read options specific to round robin router. */ - MXS_CONFIG_PARAMETER* params = service->svc_config_param; - m_max_backends = params->get_integer(MAX_BACKENDS); - m_write_server = params->get_server(WRITE_BACKEND); - m_print_on_routing = params->get_bool(PRINT_ON_ROUTING); - m_example_enum = params->get_enum(DUMMY, enum_example); + const MXS_CONFIG_PARAMETER& params = service->svc_config_param; + m_max_backends = params.get_integer(MAX_BACKENDS); + m_write_server = params.get_server(WRITE_BACKEND); + m_print_on_routing = params.get_bool(PRINT_ON_ROUTING); + m_example_enum = params.get_enum(DUMMY, enum_example); RR_DEBUG("Settings read:"); RR_DEBUG("'%s': %d", MAX_BACKENDS, m_max_backends); diff --git a/include/maxscale/monitor.hh b/include/maxscale/monitor.hh index a7f8532e7..39460cbce 100644 --- a/include/maxscale/monitor.hh +++ b/include/maxscale/monitor.hh @@ -315,7 +315,7 @@ public: uint64_t m_ticks {0}; /**< Number of performed monitoring intervals */ uint8_t m_journal_hash[SHA_DIGEST_LENGTH]; /**< SHA1 hash of the latest written journal */ - MXS_CONFIG_PARAMETER* parameters = nullptr; /**< Configuration parameters */ + MXS_CONFIG_PARAMETER parameters; /**< Configuration parameters */ std::vector m_servers; /**< Monitored servers */ protected: diff --git a/include/maxscale/service.hh b/include/maxscale/service.hh index 83e997f12..25b5045ff 100644 --- a/include/maxscale/service.hh +++ b/include/maxscale/service.hh @@ -112,8 +112,7 @@ public: bool enable_root; /**< Allow root user access */ bool localhost_match_wildcard_host; /**< Match localhost against wildcard * */ - MXS_CONFIG_PARAMETER* svc_config_param; /**< list of config params and values - * */ + MXS_CONFIG_PARAMETER svc_config_param; /**< list of config params and values */ int svc_config_version; /**< Version number of configuration * */ bool svc_do_shutdown; /**< tells the service to exit loops @@ -156,8 +155,7 @@ public: protected: SERVICE(const std::string& name, const std::string& router_name) - : svc_config_param(new MXS_CONFIG_PARAMETER) - , m_name(name) /** Service name. */ + : m_name(name) /** Service name. */ , m_router_name(router_name) /** Router module. */ { } diff --git a/server/core/config.cc b/server/core/config.cc index 652b52ddd..3463fa832 100644 --- a/server/core/config.cc +++ b/server/core/config.cc @@ -4899,7 +4899,7 @@ void dump_if_changed(const MXS_MODULE_PARAM* params, } void dump_param_list(int file, - MXS_CONFIG_PARAMETER* list, + const MXS_CONFIG_PARAMETER* list, const std::unordered_set& ignored, const MXS_MODULE_PARAM* common_params, const MXS_MODULE_PARAM* module_params) diff --git a/server/core/config_runtime.cc b/server/core/config_runtime.cc index f58b02f61..de218ef25 100644 --- a/server/core/config_runtime.cc +++ b/server/core/config_runtime.cc @@ -604,7 +604,7 @@ bool do_alter_monitor(Monitor* monitor, const char* key, const char* value) } std::lock_guard guard(crt_lock); - monitor->parameters->set(key, value); + monitor->parameters.set(key, value); bool success = true; if (strcmp(key, CN_USER) == 0) { @@ -695,7 +695,7 @@ bool runtime_alter_monitor(Monitor* monitor, const char* key, const char* value) } if (was_running) { - MonitorManager::monitor_start(monitor, monitor->parameters); + MonitorManager::monitor_start(monitor, &monitor->parameters); } return success; } @@ -729,10 +729,10 @@ bool runtime_alter_service(Service* service, const char* zKey, const char* zValu if (service->router->configureInstance && service->capabilities & RCAP_TYPE_RUNTIME_CONFIG) { // Stash the old value in case the reconfiguration fails. - std::string old_value = service->svc_config_param->get_string(key); + std::string old_value = service->svc_config_param.get_string(key); service_replace_parameter(service, key.c_str(), value.c_str()); - if (!service->router->configureInstance(service->router_instance, service->svc_config_param)) + if (!service->router->configureInstance(service->router_instance, &service->svc_config_param)) { // Reconfiguration failed, restore the old value of the parameter if (old_value.empty()) @@ -2258,7 +2258,7 @@ Monitor* runtime_create_monitor_from_json(json_t* json) } else { - MonitorManager::monitor_start(rval, rval->parameters); + MonitorManager::monitor_start(rval, &rval->parameters); } } } @@ -2440,7 +2440,7 @@ bool runtime_alter_monitor_from_json(Monitor* monitor, json_t* new_json) if (restart) { - MonitorManager::monitor_start(monitor, monitor->parameters); + MonitorManager::monitor_start(monitor, &monitor->parameters); } } } diff --git a/server/core/internal/config.hh b/server/core/internal/config.hh index 12370d1ae..b5b4f7654 100644 --- a/server/core/internal/config.hh +++ b/server/core/internal/config.hh @@ -235,7 +235,7 @@ bool get_suffixed_duration(const char* zValue, // Dump a parameter list into a file as `key=value` pairs void dump_param_list(int file, - MXS_CONFIG_PARAMETER* list, + const MXS_CONFIG_PARAMETER* list, const std::unordered_set& ignored, const MXS_MODULE_PARAM* common_params, const MXS_MODULE_PARAM* module_params); diff --git a/server/core/monitor.cc b/server/core/monitor.cc index 924e95022..1ecfe0fe1 100644 --- a/server/core/monitor.cc +++ b/server/core/monitor.cc @@ -184,7 +184,6 @@ Monitor::Monitor(const string& name, const string& module) , m_module(module) { memset(m_journal_hash, 0, sizeof(m_journal_hash)); - parameters = new MXS_CONFIG_PARAMETER; } void Monitor::stop() @@ -236,16 +235,15 @@ bool Monitor::configure_base(const MXS_CONFIG_PARAMETER* params) if (!error) { // Store module name into parameter storage. - parameters->set(CN_MODULE, m_module); + parameters.set(CN_MODULE, m_module); // Add all config settings to text-mode storage. Needed for serialization. - parameters->set_multiple(*params); + parameters.set_multiple(*params); } return !error; } Monitor::~Monitor() { - delete parameters; monitor_server_free_all(m_servers); MXS_FREE((const_cast(m_name))); } @@ -297,7 +295,7 @@ void monitor_start_all() this_unit.foreach_monitor([](Monitor* monitor) { if (monitor->m_active) { - MonitorManager::monitor_start(monitor, monitor->parameters); + MonitorManager::monitor_start(monitor, &monitor->parameters); } return true; }); @@ -367,7 +365,7 @@ bool Monitor::add_server(Monitor* mon, SERVER* server) if (old_state == MONITOR_STATE_RUNNING) { - MonitorManager::monitor_start(mon, mon->parameters); + MonitorManager::monitor_start(mon, &mon->parameters); } } @@ -455,7 +453,7 @@ void Monitor::remove_server(Monitor* mon, SERVER* server) if (old_state == MONITOR_STATE_RUNNING) { - MonitorManager::monitor_start(mon, mon->parameters); + MonitorManager::monitor_start(mon, &mon->parameters); } } @@ -1436,7 +1434,7 @@ static bool create_monitor_config(const Monitor* monitor, const char* filename) mxb_assert(mod); dump_param_list(file, - monitor->parameters, + &monitor->parameters, {CN_TYPE, CN_SERVERS}, config_monitor_params, mod->parameters); @@ -1620,7 +1618,7 @@ json_t* monitor_parameters_to_json(const Monitor* monitor) { json_t* rval = json_object(); const MXS_MODULE* mod = get_module(monitor->m_module.c_str(), MODULE_MONITOR); - config_add_module_params_json(monitor->parameters, + config_add_module_params_json(&monitor->parameters, {CN_TYPE, CN_MODULE, CN_SERVERS}, config_monitor_params, mod->parameters, diff --git a/server/core/resource.cc b/server/core/resource.cc index 33d3fbdea..5a43d7892 100644 --- a/server/core/resource.cc +++ b/server/core/resource.cc @@ -272,7 +272,7 @@ HttpResponse cb_start_monitor(const HttpRequest& request) Monitor* monitor = monitor_find(request.uri_part(1).c_str()); if (monitor) { - MonitorManager::monitor_start(monitor, monitor->parameters); + MonitorManager::monitor_start(monitor, &monitor->parameters); } return HttpResponse(MHD_HTTP_NO_CONTENT); } diff --git a/server/core/service.cc b/server/core/service.cc index 6be69fc69..d4b9683fd 100644 --- a/server/core/service.cc +++ b/server/core/service.cc @@ -273,8 +273,6 @@ Service::~Service() dbref = dbref->next; MXS_FREE(tmp); } - - delete svc_config_param; } void service_free(Service* service) @@ -1150,7 +1148,7 @@ int service_refresh_users(SERVICE* svc) void service_add_parameters(Service* service, const MXS_CONFIG_PARAMETER* param) { - service->svc_config_param->set_multiple(*param); + service->svc_config_param.set_multiple(*param); } void service_add_parameter(Service* service, const char* key, const char* value) @@ -1162,12 +1160,12 @@ void service_add_parameter(Service* service, const char* key, const char* value) void service_remove_parameter(Service* service, const char* key) { - service->svc_config_param->remove(key); + service->svc_config_param.remove(key); } void service_replace_parameter(Service* service, const char* key, const char* value) { - service->svc_config_param->set(key, value); + service->svc_config_param.set(key, value); } /** @@ -1467,7 +1465,7 @@ bool Service::dump_config(const char* filename) const mxb_assert(mod); dump_param_list(file, - svc_config_param, + &svc_config_param, {CN_TYPE, CN_FILTERS, CN_SERVERS}, config_service_params, mod->parameters); @@ -1579,7 +1577,7 @@ json_t* service_parameters_to_json(const SERVICE* service) json_t* rval = json_object(); const MXS_MODULE* mod = get_module(service->router_name(), MODULE_ROUTER); - config_add_module_params_json(service->svc_config_param, + config_add_module_params_json(&service->svc_config_param, {CN_TYPE, CN_ROUTER, CN_SERVERS, CN_FILTERS}, config_service_params, mod->parameters, diff --git a/server/modules/monitor/mariadbmon/cluster_manipulation.cc b/server/modules/monitor/mariadbmon/cluster_manipulation.cc index 63ff1dcb0..655cb806c 100644 --- a/server/modules/monitor/mariadbmon/cluster_manipulation.cc +++ b/server/modules/monitor/mariadbmon/cluster_manipulation.cc @@ -64,7 +64,7 @@ bool MariaDBMonitor::manual_switchover(SERVER* promotion_server, SERVER* demotio { string msg = string_printf(SWITCHOVER_FAIL, op->demotion.target->name(), op->promotion.target->name()); - bool failover_setting = parameters->get_bool(CN_AUTO_FAILOVER); + bool failover_setting = parameters.get_bool(CN_AUTO_FAILOVER); if (failover_setting) { disable_setting(CN_AUTO_FAILOVER); diff --git a/server/modules/monitor/mariadbmon/mariadbmon.cc b/server/modules/monitor/mariadbmon/mariadbmon.cc index 36cb0a610..17a39e5fa 100644 --- a/server/modules/monitor/mariadbmon/mariadbmon.cc +++ b/server/modules/monitor/mariadbmon/mariadbmon.cc @@ -698,7 +698,7 @@ void MariaDBMonitor::assign_new_master(MariaDBServer* new_master) */ void MariaDBMonitor::disable_setting(const std::string& setting) { - parameters->set(setting, "false"); + parameters.set(setting, "false"); } /** diff --git a/server/modules/routing/avrorouter/avro.cc b/server/modules/routing/avrorouter/avro.cc index ff4dd970b..1f9c09ef9 100644 --- a/server/modules/routing/avrorouter/avro.cc +++ b/server/modules/routing/avrorouter/avro.cc @@ -61,12 +61,12 @@ using namespace maxscale; */ void Avro::read_source_service_options(SERVICE* source) { - MXS_CONFIG_PARAMETER* params = source->svc_config_param; - binlogdir = params->get_string("binlogdir"); - filestem = params->get_string("filestem"); + MXS_CONFIG_PARAMETER& params = source->svc_config_param; + binlogdir = params.get_string("binlogdir"); + filestem = params.get_string("filestem"); mxb_assert(!binlogdir.empty() && !filestem.empty()); - for (const auto& opt : mxs::strtok(params->get_string("router_options"), ", \t")) + for (const auto& opt : mxs::strtok(params.get_string("router_options"), ", \t")) { auto kv = mxs::strtok(opt, "="); @@ -85,7 +85,7 @@ void Avro::read_source_service_options(SERVICE* source) Avro* Avro::create(SERVICE* service, SRowEventHandler handler) { SERVICE* source_service = NULL; - std::string source_name = service->svc_config_param->get_string("source"); + std::string source_name = service->svc_config_param.get_string("source"); if (!source_name.empty()) { @@ -115,7 +115,7 @@ Avro* Avro::create(SERVICE* service, SRowEventHandler handler) } } - return new(std::nothrow) Avro(service, service->svc_config_param, source_service, handler); + return new(std::nothrow) Avro(service, &service->svc_config_param, source_service, handler); } Avro::Avro(SERVICE* service, MXS_CONFIG_PARAMETER* params, SERVICE* source, SRowEventHandler handler) diff --git a/server/modules/routing/avrorouter/avro_main.cc b/server/modules/routing/avrorouter/avro_main.cc index 613b79d88..2e240ae0f 100644 --- a/server/modules/routing/avrorouter/avro_main.cc +++ b/server/modules/routing/avrorouter/avro_main.cc @@ -60,10 +60,10 @@ static bool conversion_task_ctl(Avro* inst, bool start); */ MXS_ROUTER* createInstance(SERVICE* service, MXS_CONFIG_PARAMETER* params) { - uint64_t block_size = service->svc_config_param->get_size("block_size"); + uint64_t block_size = service->svc_config_param.get_size("block_size"); mxs_avro_codec_type codec = static_cast( - service->svc_config_param->get_enum("codec", codec_values)); - std::string avrodir = service->svc_config_param->get_string("avrodir"); + service->svc_config_param.get_enum("codec", codec_values)); + std::string avrodir = service->svc_config_param.get_string("avrodir"); SRowEventHandler handler(new AvroConverter(avrodir, block_size, codec)); Avro* router = Avro::create(service, handler); diff --git a/server/modules/routing/debugcli/debugcmd.cc b/server/modules/routing/debugcli/debugcmd.cc index 5a4ef42fe..15599411f 100644 --- a/server/modules/routing/debugcli/debugcmd.cc +++ b/server/modules/routing/debugcli/debugcmd.cc @@ -2727,7 +2727,7 @@ static void shutdown_monitor(DCB* dcb, Monitor* monitor) */ static void restart_monitor(DCB* dcb, Monitor* monitor) { - MonitorManager::monitor_start(monitor, monitor->parameters); + MonitorManager::monitor_start(monitor, &monitor->parameters); } /** diff --git a/server/modules/routing/maxinfo/maxinfo_exec.cc b/server/modules/routing/maxinfo/maxinfo_exec.cc index 091f67adf..30d8659e0 100644 --- a/server/modules/routing/maxinfo/maxinfo_exec.cc +++ b/server/modules/routing/maxinfo/maxinfo_exec.cc @@ -615,7 +615,7 @@ void exec_restart_monitor(DCB* dcb, MAXINFO_TREE* tree) Monitor* monitor = monitor_find(tree->value); if (monitor) { - MonitorManager::monitor_start(monitor, monitor->parameters); + MonitorManager::monitor_start(monitor, &monitor->parameters); maxinfo_send_ok(dcb); } else