From cbb8c68770a50bae3178cd02008cbf48798d2083 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Tue, 10 Jul 2018 05:42:01 +0300 Subject: [PATCH] Remove router_options Relaced router_options with configuration parameters in the createInstance router entry point. The same needs to be done for the filter API as barely any filters use the feature. Some routers (binlogrouter) still support router_options but using it is deprecated. This had to be done as their use wasn't deprecated in 2.2. --- .../MaxScale-2.3.0-Release-Notes.md | 5 + examples/roundrobinrouter.cpp | 4 +- examples/testroute.c | 5 +- include/maxscale/router.h | 6 +- include/maxscale/router.hh | 6 +- include/maxscale/service.h | 1 - server/core/config.cc | 11 -- server/core/internal/service.h | 6 - server/core/service.cc | 116 +----------------- server/modules/routing/avrorouter/avro.cc | 30 ++--- .../modules/routing/avrorouter/avro_main.cc | 2 +- server/modules/routing/binlogrouter/blr.cc | 7 +- server/modules/routing/cat/cat.cc | 2 +- server/modules/routing/cat/cat.hh | 2 +- server/modules/routing/cli/cli.cc | 14 +-- server/modules/routing/debugcli/debugcli.cc | 6 +- .../modules/routing/hintrouter/hintrouter.cc | 3 +- .../modules/routing/hintrouter/hintrouter.hh | 2 +- server/modules/routing/maxinfo/maxinfo.cc | 13 +- .../routing/readconnroute/readconnroute.cc | 6 +- .../routing/readwritesplit/readwritesplit.cc | 6 +- .../routing/readwritesplit/readwritesplit.hh | 2 +- .../schemarouter/schemarouterinstance.cc | 8 +- .../schemarouter/schemarouterinstance.hh | 2 +- 24 files changed, 49 insertions(+), 216 deletions(-) diff --git a/Documentation/Release-Notes/MaxScale-2.3.0-Release-Notes.md b/Documentation/Release-Notes/MaxScale-2.3.0-Release-Notes.md index c3d32643c..0698fac49 100644 --- a/Documentation/Release-Notes/MaxScale-2.3.0-Release-Notes.md +++ b/Documentation/Release-Notes/MaxScale-2.3.0-Release-Notes.md @@ -58,6 +58,11 @@ The use of `router_options` with avrorouter was deprecated in MaxScale 2.1. In MaxScale 2.3, the use of `router_options` is no longer supported and the options should be given as parameters instead. +### `router_options` in readwritesplit + +The use of `router_options` with readwritesplit, which was deprecated in +MaxScale 2.2.0, has been removed in MaxScale 2.3.0. + ### `QUERY-LAST-TRANSACTION` and `QUERY-TRANSACTION` CDC commands The CDC protocol no longer accepts the `QUERY-LAST-TRANSACTION` and diff --git a/examples/roundrobinrouter.cpp b/examples/roundrobinrouter.cpp index edaf4a55a..f4cd58496 100644 --- a/examples/roundrobinrouter.cpp +++ b/examples/roundrobinrouter.cpp @@ -567,7 +567,7 @@ void RRRouter::decide_target(RRRouterSession* rses, GWBUF* querybuf, DCB*& targe * The functions implementing the router module API. These do not need to be * "extern C", but they do need to be callable from C code. */ -static MXS_ROUTER* createInstance(SERVICE* service, char** options); +static MXS_ROUTER* createInstance(SERVICE* service, MXS_CONFIG_PARAMETER* params); static MXS_ROUTER_SESSION* newSession(MXS_ROUTER* instance, MXS_SESSION* session); static void closeSession(MXS_ROUTER* instance, MXS_ROUTER_SESSION* session); static void freeSession(MXS_ROUTER* instance, MXS_ROUTER_SESSION* session); @@ -663,7 +663,7 @@ MXS_MODULE* MXS_CREATE_MODULE() * @param options The options for this query router * @return NULL in failure, pointer to router in success. */ -static MXS_ROUTER* createInstance(SERVICE* service, char** options) +static MXS_ROUTER* createInstance(SERVICE* service, MXS_CONFIG_PARAMETER* params) { RRRouter* instance = NULL; /* The core of MaxScale is written in C and does not understand exceptions. diff --git a/examples/testroute.c b/examples/testroute.c index d506eba1b..b7ee822d2 100644 --- a/examples/testroute.c +++ b/examples/testroute.c @@ -15,7 +15,7 @@ #include #include -static MXS_ROUTER *createInstance(SERVICE *service, char **options); +static MXS_ROUTER *createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params); static MXS_ROUTER_SESSION *newSession(MXS_ROUTER *instance, MXS_SESSION *session); static void closeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *session); static void freeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *session); @@ -94,8 +94,7 @@ MXS_MODULE* MXS_CREATE_MODULE() * * @return The instance data for this new instance */ -static MXS_ROUTER * -createInstance(SERVICE *service, char **options) +static MXS_ROUTER* createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params) { return (MXS_ROUTER*)MXS_MALLOC(sizeof(TESTROUTER)); } diff --git a/include/maxscale/router.h b/include/maxscale/router.h index 144034f4c..1e1ac7735 100644 --- a/include/maxscale/router.h +++ b/include/maxscale/router.h @@ -90,11 +90,11 @@ typedef struct mxs_router_object * other API functions. * * @param service The service where the instance is created - * @param options Router options + * @param params Parameters for the router * * @return New router instance on NULL on error */ - MXS_ROUTER *(*createInstance)(SERVICE *service, char **options); + MXS_ROUTER *(*createInstance)(SERVICE* service, MXS_CONFIG_PARAMETER* params); /** * Called to create a new user session within the router @@ -240,7 +240,7 @@ typedef struct mxs_router_object * must update these versions numbers in accordance with the rules in * modinfo.h. */ -#define MXS_ROUTER_VERSION { 3, 1, 0 } +#define MXS_ROUTER_VERSION { 4, 0, 0 } /** * Specifies capabilities specific for routers. Common capabilities diff --git a/include/maxscale/router.hh b/include/maxscale/router.hh index 0b7507462..e2ff948de 100644 --- a/include/maxscale/router.hh +++ b/include/maxscale/router.hh @@ -98,7 +98,7 @@ protected: * class MyRouter : public maxscale::Router * { * public: - * static MyRouter* create(SERVICE* pService, char** pzOptions); + * static MyRouter* create(SERVICE* pService, MXS_CONFIG_PARAMETER* params); * * MyRouterSession* newSession(MXS_SESSION* pSession); * @@ -137,11 +137,11 @@ public: return false; } - static MXS_ROUTER* createInstance(SERVICE* pService, char** pzOptions) + static MXS_ROUTER* createInstance(SERVICE* pService, MXS_CONFIG_PARAMETER* params) { RouterType* pRouter = NULL; - MXS_EXCEPTION_GUARD(pRouter = RouterType::create(pService, pzOptions)); + MXS_EXCEPTION_GUARD(pRouter = RouterType::create(pService, params)); return pRouter; } diff --git a/include/maxscale/service.h b/include/maxscale/service.h index 0db4a86c3..887a0eb4b 100644 --- a/include/maxscale/service.h +++ b/include/maxscale/service.h @@ -129,7 +129,6 @@ typedef struct service SERV_LISTENER *ports; /**< Linked list of ports and protocols * that this service will listen on */ char *routerModule; /**< Name of router module to use */ - char **routerOptions; /**< Router specific option strings */ struct mxs_router_object *router; /**< The router we are using */ struct mxs_router *router_instance;/**< The router instance for this service */ char version_string[MAX_SERVICE_VERSION_LEN]; /**< version string for this service listeners */ diff --git a/server/core/config.cc b/server/core/config.cc index c21360584..d7ed5b19b 100644 --- a/server/core/config.cc +++ b/server/core/config.cc @@ -3316,17 +3316,6 @@ int configure_new_service(CONFIG_CONTEXT *context, CONFIG_CONTEXT *obj) } } - if (roptions) - { - char *lasts; - char *s = strtok_r(roptions, ",", &lasts); - while (s) - { - serviceAddRouterOption(service, s); - s = strtok_r(NULL, ",", &lasts); - } - } - if (filters) { if (!serviceSetFilters(service, filters)) diff --git a/server/core/internal/service.h b/server/core/internal/service.h index 1239983c0..b0b6aa9df 100644 --- a/server/core/internal/service.h +++ b/server/core/internal/service.h @@ -110,12 +110,6 @@ bool service_server_in_use(const SERVER *server); /** Update the server weights used by services */ void service_update_weights(); -/** - * Alteration of the service configuration - */ -void serviceAddRouterOption(SERVICE *service, char *option); -void serviceClearRouterOptions(SERVICE *service); - /** * @brief Add parameters to a service * diff --git a/server/core/service.cc b/server/core/service.cc index e707c2050..12ab15c8b 100644 --- a/server/core/service.cc +++ b/server/core/service.cc @@ -127,7 +127,6 @@ SERVICE* service_alloc(const char *name, const char *router) service->retry_start = true; service->conn_idle_timeout = SERVICE_NO_SESSION_TIMEOUT; service->svc_config_param = NULL; - service->routerOptions = NULL; service->log_auth_warnings = true; service->strip_db_esc = true; service->rate_limits = rate_limits; @@ -420,47 +419,6 @@ int serviceStartAllPorts(SERVICE* service) return listeners; } -/** Helper function for copying an array of strings */ -static char** copy_string_array(char** original) -{ - char **array = NULL; - - if (original) - { - int values = 0; - - while (original[values]) - { - values++; - } - - array = (char**)MXS_MALLOC(sizeof(char*) * (values + 1)); - - if (array) - { - for (int i = 0; i < values; i++) - { - array[i] = MXS_STRDUP_A(original[i]); - } - array[values] = NULL; - } - } - return array; -} - -/** Helper function for freeing an array of strings */ -static void free_string_array(char** array) -{ - if (array) - { - for (int i = 0; array[i]; i++) - { - MXS_FREE(array[i]); - } - MXS_FREE(array); - } -} - /** * Start a service * @@ -478,9 +436,8 @@ int serviceInitialize(SERVICE *service) service_calculate_weights(service); int listeners = 0; - char **router_options = copy_string_array(service->routerOptions); - if ((service->router_instance = service->router->createInstance(service, router_options))) + if ((service->router_instance = service->router->createInstance(service, service->svc_config_param))) { if (service->router->getCapabilities) { @@ -503,8 +460,6 @@ int serviceInitialize(SERVICE *service) service->state = SERVICE_STATE_FAILED; } - free_string_array(router_options); - return listeners; } @@ -959,62 +914,6 @@ serviceHasBackend(SERVICE *service, SERVER *server) return ptr != NULL; } -/** - * Add a router option to a service - * - * @param service The service to add the router option to - * @param option The option string - */ -void -serviceAddRouterOption(SERVICE *service, char *option) -{ - int i; - - spinlock_acquire(&service->spin); - if (service->routerOptions == NULL) - { - service->routerOptions = (char **)MXS_CALLOC(2, sizeof(char *)); - MXS_ABORT_IF_NULL(service->routerOptions); - service->routerOptions[0] = MXS_STRDUP_A(option); - service->routerOptions[1] = NULL; - } - else - { - for (i = 0; service->routerOptions[i]; i++) - { - ; - } - service->routerOptions = (char **)MXS_REALLOC(service->routerOptions, (i + 2) * sizeof(char *)); - MXS_ABORT_IF_NULL(service->routerOptions); - service->routerOptions[i] = MXS_STRDUP_A(option); - service->routerOptions[i + 1] = NULL; - } - spinlock_release(&service->spin); -} - -/** - * Remove the router options for the service - * - * @param service The service to remove the options from - */ -void -serviceClearRouterOptions(SERVICE *service) -{ - int i; - - spinlock_acquire(&service->spin); - if (service->routerOptions != NULL) - { - for (i = 0; service->routerOptions[i]; i++) - { - MXS_FREE(service->routerOptions[i]); - } - MXS_FREE(service->routerOptions); - service->routerOptions = NULL; - } - spinlock_release(&service->spin); -} - /** * Set the service user that is used to log in to the backebd servers * associated with this service. @@ -2427,18 +2326,7 @@ json_t* service_parameters_to_json(const SERVICE* service) { json_t* rval = json_object(); - string options; - - if (service->routerOptions && service->routerOptions[0]) - { - options += service->routerOptions[0]; - - for (int i = 1; service->routerOptions[i]; i++) - { - options += ","; - options += service->routerOptions[i]; - } - } + string options{config_get_string(service->svc_config_param, "router_options")}; json_object_set_new(rval, CN_ROUTER_OPTIONS, json_string(options.c_str())); json_object_set_new(rval, CN_USER, json_string(service->credentials.name)); diff --git a/server/modules/routing/avrorouter/avro.cc b/server/modules/routing/avrorouter/avro.cc index 0345f36e7..560cbb950 100644 --- a/server/modules/routing/avrorouter/avro.cc +++ b/server/modules/routing/avrorouter/avro.cc @@ -62,7 +62,6 @@ using namespace maxscale; */ void Avro::read_source_service_options(SERVICE* source) { - char** options = source->routerOptions; MXS_CONFIG_PARAMETER* params = source->svc_config_param; for (MXS_CONFIG_PARAMETER* p = params; p; p = p->next) @@ -77,28 +76,17 @@ void Avro::read_source_service_options(SERVICE* source) } } - if (options) + for (auto&& opt: mxs::strtok(config_get_string(params, "router_options"), ", \t")) { - for (int i = 0; options[i]; i++) + auto&& kv = mxs::strtok(opt, "="); + + if (kv[0] == "binlogdir") { - char option[strlen(options[i]) + 1]; - strcpy(option, options[i]); - - char *value = strchr(option, '='); - if (value) - { - *value++ = '\0'; - value = trim(value); - - if (strcmp(option, "binlogdir") == 0) - { - binlogdir = value; - } - else if (strcmp(option, "filestem") == 0) - { - filestem = value; - } - } + binlogdir = kv[1]; + } + else if (kv[0] == "filestem") + { + filestem = kv[1]; } } } diff --git a/server/modules/routing/avrorouter/avro_main.cc b/server/modules/routing/avrorouter/avro_main.cc index 4c997c4ba..a8d876d3b 100644 --- a/server/modules/routing/avrorouter/avro_main.cc +++ b/server/modules/routing/avrorouter/avro_main.cc @@ -59,7 +59,7 @@ static bool conversion_task_ctl(Avro *inst, bool start); * * @return The instance data for this new instance */ -MXS_ROUTER* createInstance(SERVICE *service, char **options) +MXS_ROUTER* createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params) { uint64_t block_size = config_get_size(service->svc_config_param, "block_size"); mxs_avro_codec_type codec = static_cast(config_get_enum(service->svc_config_param, diff --git a/server/modules/routing/binlogrouter/blr.cc b/server/modules/routing/binlogrouter/blr.cc index 78e015f66..875404fd9 100644 --- a/server/modules/routing/binlogrouter/blr.cc +++ b/server/modules/routing/binlogrouter/blr.cc @@ -54,7 +54,7 @@ #include /* The router entry points */ -static MXS_ROUTER *createInstance(SERVICE *service, char **options); +static MXS_ROUTER *createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params); static void free_instance(ROUTER_INSTANCE *instance); static MXS_ROUTER_SESSION *newSession(MXS_ROUTER *instance, MXS_SESSION *session); @@ -233,8 +233,7 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE() * * @return The instance data for this new instance */ -static MXS_ROUTER * -createInstance(SERVICE *service, char **options) +static MXS_ROUTER* createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params) { ROUTER_INSTANCE *inst; uuid_t defuuid; @@ -322,8 +321,6 @@ createInstance(SERVICE *service, char **options) strcpy(inst->binlog_name, ""); strcpy(inst->prevbinlog, ""); - MXS_CONFIG_PARAMETER *params = service->svc_config_param; - inst->initbinlog = config_get_integer(params, "file"); inst->short_burst = config_get_integer(params, "shortburst"); diff --git a/server/modules/routing/cat/cat.cc b/server/modules/routing/cat/cat.cc index 493307476..6626e4469 100644 --- a/server/modules/routing/cat/cat.cc +++ b/server/modules/routing/cat/cat.cc @@ -25,7 +25,7 @@ Cat::~Cat() { } -Cat* Cat::create(SERVICE* pService, char** pzOptions) +Cat* Cat::create(SERVICE* pService, MXS_CONFIG_PARAMETER* params) { return new Cat(pService); } diff --git a/server/modules/routing/cat/cat.hh b/server/modules/routing/cat/cat.hh index f823ec1d7..6175330df 100644 --- a/server/modules/routing/cat/cat.hh +++ b/server/modules/routing/cat/cat.hh @@ -25,7 +25,7 @@ class Cat: public mxs::Router Cat& operator =(const Cat&) = delete; public: ~Cat(); - static Cat* create(SERVICE* pService, char** pzOptions); + static Cat* create(SERVICE* pService, MXS_CONFIG_PARAMETER* params); CatSession* newSession(MXS_SESSION* pSession); void diagnostics(DCB* pDcb); json_t* diagnostics_json() const; diff --git a/server/modules/routing/cli/cli.cc b/server/modules/routing/cli/cli.cc index 4875aed6a..4a7de00ea 100644 --- a/server/modules/routing/cli/cli.cc +++ b/server/modules/routing/cli/cli.cc @@ -43,7 +43,7 @@ #include /* The router entry points */ -static MXS_ROUTER *createInstance(SERVICE *service, char **options); +static MXS_ROUTER *createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params); static MXS_ROUTER_SESSION *newSession(MXS_ROUTER *instance, MXS_SESSION *session); static void closeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session); static void freeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session); @@ -116,11 +116,9 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE() * * @return The instance data for this new instance */ -static MXS_ROUTER * -createInstance(SERVICE *service, char **options) +static MXS_ROUTER* createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params) { CLI_INSTANCE *inst; - int i; if ((inst = static_cast(MXS_MALLOC(sizeof(CLI_INSTANCE)))) == NULL) { @@ -131,14 +129,6 @@ createInstance(SERVICE *service, char **options) spinlock_init(&inst->lock); inst->sessions = NULL; - if (options) - { - for (i = 0; options[i]; i++) - { - MXS_ERROR("Unknown option for CLI '%s'", options[i]); - } - } - /* * We have completed the creation of the instance data, so now * insert this router instance into the linked list of routers diff --git a/server/modules/routing/debugcli/debugcli.cc b/server/modules/routing/debugcli/debugcli.cc index 30f598480..78fbe0f16 100644 --- a/server/modules/routing/debugcli/debugcli.cc +++ b/server/modules/routing/debugcli/debugcli.cc @@ -42,7 +42,7 @@ #include /* The router entry points */ -static MXS_ROUTER *createInstance(SERVICE *service, char **options); +static MXS_ROUTER *createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params); static MXS_ROUTER_SESSION *newSession(MXS_ROUTER *instance, MXS_SESSION *session); static void closeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session); static void freeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session); @@ -115,11 +115,9 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE() * * @return The instance data for this new instance */ -static MXS_ROUTER * -createInstance(SERVICE *service, char **options) +static MXS_ROUTER* createInstance(SERVICE* service, MXS_CONFIG_PARAMETER* params) { CLI_INSTANCE *inst; - int i; if ((inst = static_cast(MXS_MALLOC(sizeof(CLI_INSTANCE)))) == NULL) { diff --git a/server/modules/routing/hintrouter/hintrouter.cc b/server/modules/routing/hintrouter/hintrouter.cc index 8f5efad2a..aaeec4dee 100644 --- a/server/modules/routing/hintrouter/hintrouter.cc +++ b/server/modules/routing/hintrouter/hintrouter.cc @@ -54,11 +54,10 @@ HintRouter::HintRouter(SERVICE* pService, HINT_TYPE default_action, string& defa } //static -HintRouter* HintRouter::create(SERVICE* pService, char** pzOptions) +HintRouter* HintRouter::create(SERVICE* pService, MXS_CONFIG_PARAMETER* params) { HR_ENTRY(); - MXS_CONFIG_PARAMETER* params = pService->svc_config_param; HINT_TYPE default_action = (HINT_TYPE)config_get_enum(params, DEFAULT_ACTION, default_action_values); string default_server(config_get_string(params, DEFAULT_SERVER)); diff --git a/server/modules/routing/hintrouter/hintrouter.hh b/server/modules/routing/hintrouter/hintrouter.hh index f59aa607c..ad11d17e7 100644 --- a/server/modules/routing/hintrouter/hintrouter.hh +++ b/server/modules/routing/hintrouter/hintrouter.hh @@ -20,7 +20,7 @@ class HintRouter : public maxscale::Router { public: - static HintRouter* create(SERVICE* pService, char** pzOptions); + static HintRouter* create(SERVICE* pService, MXS_CONFIG_PARAMETER* params); HintRouterSession* newSession(MXS_SESSION *pSession); void diagnostics(DCB* pOut); json_t* diagnostics_json() const; diff --git a/server/modules/routing/maxinfo/maxinfo.cc b/server/modules/routing/maxinfo/maxinfo.cc index 5f530b33e..2cbdeb19c 100644 --- a/server/modules/routing/maxinfo/maxinfo.cc +++ b/server/modules/routing/maxinfo/maxinfo.cc @@ -66,7 +66,7 @@ static int handle_url(INFO_INSTANCE *instance, INFO_SESSION *router_session, GWB static int maxinfo_send_ok(DCB *dcb); /* The router entry points */ -static MXS_ROUTER *createInstance(SERVICE *service, char **options); +static MXS_ROUTER *createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params); static MXS_ROUTER_SESSION *newSession(MXS_ROUTER *instance, MXS_SESSION *session); static void closeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session); static void freeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session); @@ -143,8 +143,7 @@ extern "C" MXS_MODULE* MXS_CREATE_MODULE() * * @return The instance data for this new instance */ -static MXS_ROUTER * -createInstance(SERVICE *service, char **options) +static MXS_ROUTER* createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params) { INFO_INSTANCE *inst; int i; @@ -158,14 +157,6 @@ createInstance(SERVICE *service, char **options) inst->service = service; spinlock_init(&inst->lock); - if (options) - { - for (i = 0; options[i]; i++) - { - MXS_ERROR("Unknown option for MaxInfo '%s'", options[i]); - } - } - /* * We have completed the creation of the instance data, so now * insert this router instance into the linked list of routers diff --git a/server/modules/routing/readconnroute/readconnroute.cc b/server/modules/routing/readconnroute/readconnroute.cc index b7b1dc61e..fb213d9eb 100644 --- a/server/modules/routing/readconnroute/readconnroute.cc +++ b/server/modules/routing/readconnroute/readconnroute.cc @@ -91,7 +91,7 @@ #include /* The router entry points */ -static MXS_ROUTER *createInstance(SERVICE *service, char **options); +static MXS_ROUTER *createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params); static MXS_ROUTER_SESSION *newSession(MXS_ROUTER *instance, MXS_SESSION *session); static void closeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session); static void freeSession(MXS_ROUTER *instance, MXS_ROUTER_SESSION *router_session); @@ -234,7 +234,7 @@ static bool configureInstance(MXS_ROUTER* instance, MXS_CONFIG_PARAMETER* params * * @return The instance data for this new instance */ -static MXS_ROUTER* createInstance(SERVICE *service, char **options) +static MXS_ROUTER* createInstance(SERVICE *service, MXS_CONFIG_PARAMETER* params) { ROUTER_INSTANCE* inst = static_cast(MXS_CALLOC(1, sizeof(ROUTER_INSTANCE))); @@ -245,7 +245,7 @@ static MXS_ROUTER* createInstance(SERVICE *service, char **options) spinlock_init(&inst->lock); inst->bitmask_and_bitvalue = 0; - if (!configureInstance((MXS_ROUTER*)inst, service->svc_config_param)) + if (!configureInstance((MXS_ROUTER*)inst, params)) { free_readconn_instance(inst); inst = nullptr; diff --git a/server/modules/routing/readwritesplit/readwritesplit.cc b/server/modules/routing/readwritesplit/readwritesplit.cc index 0a2683675..fe228ce18 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.cc +++ b/server/modules/routing/readwritesplit/readwritesplit.cc @@ -273,13 +273,11 @@ bool RWSplit::have_enough_servers() const */ -RWSplit* RWSplit::create(SERVICE *service, char **options) +RWSplit* RWSplit::create(SERVICE *service, MXS_CONFIG_PARAMETER* params) { - MXS_CONFIG_PARAMETER* params = service->svc_config_param; SConfig config(new Config(params)); - if (!handle_max_slaves(config, config_get_string(params, "max_slave_connections")) || - (options && !rwsplit_process_router_options(config, options))) + if (!handle_max_slaves(config, config_get_string(params, "max_slave_connections"))) { return NULL; } diff --git a/server/modules/routing/readwritesplit/readwritesplit.hh b/server/modules/routing/readwritesplit/readwritesplit.hh index 4d93149e6..f7e3655f1 100644 --- a/server/modules/routing/readwritesplit/readwritesplit.hh +++ b/server/modules/routing/readwritesplit/readwritesplit.hh @@ -256,7 +256,7 @@ public: * * @return New router instance or NULL on error */ - static RWSplit* create(SERVICE* pService, char** pzOptions); + static RWSplit* create(SERVICE* pService, MXS_CONFIG_PARAMETER* params); /** * @brief Create a new session for this router instance diff --git a/server/modules/routing/schemarouter/schemarouterinstance.cc b/server/modules/routing/schemarouter/schemarouterinstance.cc index b854bba0c..e31f1d02c 100644 --- a/server/modules/routing/schemarouter/schemarouterinstance.cc +++ b/server/modules/routing/schemarouter/schemarouterinstance.cc @@ -54,18 +54,16 @@ SchemaRouter::~SchemaRouter() { } -SchemaRouter* SchemaRouter::create(SERVICE* pService, char** pzOptions) +SchemaRouter* SchemaRouter::create(SERVICE* pService, MXS_CONFIG_PARAMETER* params) { - MXS_CONFIG_PARAMETER* conf = pService->svc_config_param; - - if ((config_get_param(conf, "auth_all_servers")) == NULL) + if ((config_get_param(params, "auth_all_servers")) == NULL) { MXS_NOTICE("Authentication data is fetched from all servers. To disable this " "add 'auth_all_servers=0' to the service."); pService->users_from_all = true; } - SConfig config(new Config(pService->svc_config_param)); + SConfig config(new Config(params)); return new SchemaRouter(pService, config); } diff --git a/server/modules/routing/schemarouter/schemarouterinstance.hh b/server/modules/routing/schemarouter/schemarouterinstance.hh index 9412b938a..47fd86a73 100644 --- a/server/modules/routing/schemarouter/schemarouterinstance.hh +++ b/server/modules/routing/schemarouter/schemarouterinstance.hh @@ -34,7 +34,7 @@ class SchemaRouter: public mxs::Router { public: ~SchemaRouter(); - static SchemaRouter* create(SERVICE* pService, char** pzOptions); + static SchemaRouter* create(SERVICE* pService, MXS_CONFIG_PARAMETER* params); SchemaRouterSession* newSession(MXS_SESSION* pSession); void diagnostics(DCB* pDcb); json_t* diagnostics_json() const;