From dd94374057ea36cab71ec38cbb236a8b5887f118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Mon, 20 Mar 2017 10:58:07 +0200 Subject: [PATCH] Make the getCapabitilies entry point optional The getCapabilities entry point is no longer required as long as all the relevant capabilities are added to the static module parameters. --- include/maxscale/filter.h | 12 +++++++----- include/maxscale/router.h | 10 ++++++---- server/core/service.c | 10 ++++++++-- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/include/maxscale/filter.h b/include/maxscale/filter.h index 0d2bc7918..c1a91b15c 100644 --- a/include/maxscale/filter.h +++ b/include/maxscale/filter.h @@ -51,7 +51,9 @@ typedef struct mxs_filter_session /** * @verbatim - * The "module object" structure for a filter module + * The "module object" structure for a filter module. All entry points + * marked with `(optional)` are optional entry points which can be set to NULL + * if no implementation is required. * * The entry points are: * createInstance Called by the service to create a new instance of the filter @@ -61,10 +63,10 @@ typedef struct mxs_filter_session * setDownstream Sets the downstream component of the filter pipline * setUpstream Sets the upstream component of the filter pipline * routeQuery Called on each query that requires routing - * clientReply Called for each reply packet + * clientReply Called for each reply packet (optional) * diagnostics Called for diagnostic output - * getCapabilities Called to obtain the capabilities of the filter - * destroyInstance Called for destroying a filter instance + * getCapabilities Called to obtain the capabilities of the filter (optional) + * destroyInstance Called for destroying a filter instance (optional) * * @endverbatim * @@ -97,7 +99,7 @@ typedef struct mxs_filter_object * @c setDownstream and @c setUpstream functions. * * @param instance Filter instance - * @param session Client SESSION object + * @param session Client MXS_SESSION object * * @return New filter session or NULL on error */ diff --git a/include/maxscale/router.h b/include/maxscale/router.h index bce5c0e98..0b29ad02f 100644 --- a/include/maxscale/router.h +++ b/include/maxscale/router.h @@ -58,7 +58,9 @@ typedef enum error_action /** * @verbatim - * The "module object" structure for a query router module + * The "module object" structure for a query router module. All entry points + * marked with `(optional)` are optional entry points which can be set to NULL + * if no implementation is required. * * The entry points are: * createInstance Called by the service to create a new instance of the query router @@ -67,11 +69,11 @@ typedef enum error_action * freeSession Called when a session is freed * routeQuery Called on each query that requires routing * diagnostics Called to force the router to print diagnostic output - * clientReply Called to reply to client the data from one or all backends + * clientReply Called to reply to client the data from one or all backends (optional) * handleError Called to reply to client errors with optional closeSession * or make a request for a new backend connection - * getCapabilities Called to obtain the capabilities of the router - * destroyInstance Called for destroying a router instance + * getCapabilities Called to obtain the capabilities of the router (optional) + * destroyInstance Called for destroying a router instance (optional) * * @endverbatim * diff --git a/server/core/service.c b/server/core/service.c index 1038e3ebb..c51677baa 100644 --- a/server/core/service.c +++ b/server/core/service.c @@ -488,7 +488,10 @@ int serviceInitialize(SERVICE *service) if ((service->router_instance = service->router->createInstance(service, router_options))) { - service->capabilities |= service->router->getCapabilities(service->router_instance); + if (service->router->getCapabilities) + { + service->capabilities |= service->router->getCapabilities(service->router_instance); + } if (!config_get_global_options()->config_check) { @@ -1245,7 +1248,10 @@ serviceSetFilters(SERVICE *service, char *filters) const MXS_MODULE* module = get_module(flist[n - 1]->module, MODULE_FILTER); ss_dassert(module); capabilities |= module->module_capabilities; - capabilities |= flist[n - 1]->obj->getCapabilities(flist[n - 1]->filter); + if (flist[n - 1]->obj->getCapabilities) + { + capabilities |= flist[n - 1]->obj->getCapabilities(flist[n - 1]->filter); + } } else {