Hide definition of MXS_FILTER_DEF

MXS_FILTER_DEF is now private the MaxScale core.
This commit is contained in:
Johan Wikman 2017-01-13 14:59:58 +02:00
parent 41d2d65e71
commit c13a2eeb33
8 changed files with 54 additions and 32 deletions

View File

@ -87,22 +87,13 @@ typedef struct mxs_filter_object
* file modinfo.h.
*/
#define MXS_FILTER_VERSION {2, 2, 0}
/**
* The definition of a filter from the configuration file.
* This is basically the link between a plugin to load and the
* optons to pass to that plugin.
* MXS_FILTER_DEF represents a filter definition from the configuration file.
* Its exact definition is private to MaxScale.
*/
typedef struct mxs_filter_def
{
char *name; /**< The Filter name */
char *module; /**< The module to load */
char **options; /**< The options set for this filter */
CONFIG_PARAMETER *parameters; /**< The filter parameters */
MXS_FILTER* filter; /**< The runtime filter */
MXS_FILTER_OBJECT *obj; /**< The "MODULE_OBJECT" for the filter */
SPINLOCK spin; /**< Spinlock to protect the filter definition */
struct mxs_filter_def *next; /**< Next filter in the chain of all filters */
} MXS_FILTER_DEF;
struct mxs_filter_def;
typedef struct mxs_filter_def MXS_FILTER_DEF;
/**
* Lookup a filter definition using the unique section name in
@ -114,6 +105,16 @@ typedef struct mxs_filter_def
*/
MXS_FILTER_DEF *filter_def_find(const char *name);
/**
* Get the name of a filter definition. This corresponds to
* to a filter section in the configuration file.
*
* @param filter_def A filter definition.
*
* @return The filter name.
*/
const char* filter_def_get_name(const MXS_FILTER_DEF* filter_def);
/**
* Get module name of a filter definition.
*

View File

@ -22,16 +22,17 @@
*
* @endverbatim
*/
#include <maxscale/filter.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <maxscale/filter.h>
#include <maxscale/session.h>
#include <maxscale/modules.h>
#include <maxscale/spinlock.h>
#include <maxscale/log_manager.h>
#include <maxscale/alloc.h>
#include <maxscale/log_manager.h>
#include <maxscale/modules.h>
#include <maxscale/session.h>
#include <maxscale/spinlock.h>
#include "maxscale/filter.h"
static SPINLOCK filter_spin = SPINLOCK_INIT; /**< Protects the list of all filters */
static MXS_FILTER_DEF *allFilters = NULL; /**< The list of all filters */
@ -151,6 +152,11 @@ filter_def_find(const char *name)
return filter;
}
const char* filter_def_get_name(const MXS_FILTER_DEF* filter_def)
{
return filter_def->name;
}
const char* filter_def_get_module_name(const MXS_FILTER_DEF* filter_def)
{
return filter_def->module;

View File

@ -20,6 +20,23 @@
MXS_BEGIN_DECLS
/**
* The definition of a filter from the configuration file.
* This is basically the link between a plugin to load and the
* options to pass to that plugin.
*/
typedef struct mxs_filter_def
{
char *name; /**< The Filter name */
char *module; /**< The module to load */
char **options; /**< The options set for this filter */
CONFIG_PARAMETER *parameters; /**< The filter parameters */
MXS_FILTER* filter; /**< The runtime filter */
MXS_FILTER_OBJECT *obj; /**< The "MODULE_OBJECT" for the filter */
SPINLOCK spin; /**< Spinlock to protect the filter definition */
struct mxs_filter_def *next; /**< Next filter in the chain of all filters */
} MXS_FILTER_DEF;
void filter_add_option(MXS_FILTER_DEF *filter_def, const char *option);
void filter_add_parameter(MXS_FILTER_DEF *filter_def, const char *name, const char *value);
MXS_FILTER_DEF *filter_alloc(const char *name, const char *module_name);

View File

@ -11,12 +11,13 @@
* Public License.
*/
#include <maxscale/modulecmd.h>
#include <maxscale/alloc.h>
#include <maxscale/config.h>
#include <maxscale/modulecmd.h>
#include <maxscale/pcre2.h>
#include <maxscale/platform.h>
#include <maxscale/spinlock.h>
#include "maxscale/filter.h"
/** Size of the error buffer */
#define MODULECMD_ERRBUF_SIZE 512

View File

@ -93,11 +93,9 @@ bool cache_command_show(const MODULECMD_ARG* pArgs)
const MXS_FILTER_DEF* pFilterDef = pArgs->argv[1].value.filter;
ss_dassert(pFilterDef);
ss_dassert(strcmp(pFilterDef->module, MXS_MODULE_NAME) == 0);
CacheFilter* pFilter = reinterpret_cast<CacheFilter*>(filter_def_get_instance(pFilterDef));
CacheFilter* pFilter = reinterpret_cast<CacheFilter*>(pFilterDef->filter);
pFilter->cache().show(pDcb);
MXS_EXCEPTION_GUARD(pFilter->cache().show(pDcb));
return true;
}

View File

@ -685,7 +685,7 @@ bool dbfw_reload_rules(const MODULECMD_ARG *argv)
{
bool rval = true;
MXS_FILTER_DEF *filter = argv->argv[0].value.filter;
FW_INSTANCE *inst = (FW_INSTANCE*)filter->filter;
FW_INSTANCE *inst = (FW_INSTANCE*)filter_def_get_instance(filter);
if (modulecmd_arg_is_present(argv, 1))
{
@ -750,7 +750,7 @@ bool dbfw_show_rules(const MODULECMD_ARG *argv)
{
DCB *dcb = argv->argv[0].value.dcb;
MXS_FILTER_DEF *filter = argv->argv[1].value.filter;
FW_INSTANCE *inst = (FW_INSTANCE*)filter->filter;
FW_INSTANCE *inst = (FW_INSTANCE*)filter_def_get_instance(filter);
dcb_printf(dcb, "Rule, Type, Times Matched\n");

View File

@ -43,9 +43,7 @@ bool masking_command_reload(const MODULECMD_ARG* pArgs)
const MXS_FILTER_DEF* pFilterDef = pArgs->argv[1].value.filter;
ss_dassert(pFilterDef);
ss_dassert(strcmp(pFilterDef->module, MXS_MODULE_NAME) == 0);
MaskingFilter* pFilter = reinterpret_cast<MaskingFilter*>(pFilterDef->filter);
MaskingFilter* pFilter = reinterpret_cast<MaskingFilter*>(filter_def_get_instance(pFilterDef));
MXS_EXCEPTION_GUARD(pFilter->reload(pDcb));

View File

@ -807,14 +807,15 @@ int detect_loops(TEE_INSTANCE *instance, HASHTABLE* ht, SERVICE* service)
for (i = 0; i < svc->n_filters; i++)
{
if (strcmp(svc->filters[i]->module, "tee") == 0)
const char* module = filter_def_get_module_name(svc->filters[i]);
if (strcmp(module, "tee") == 0)
{
/*
* Found a Tee filter, recurse down its path
* if the service name isn't already in the hashtable.
*/
TEE_INSTANCE* ninst = (TEE_INSTANCE*) svc->filters[i]->filter;
TEE_INSTANCE* ninst = (TEE_INSTANCE*)filter_def_get_instance(svc->filters[i]);
if (ninst == NULL)
{
/**
@ -825,7 +826,7 @@ int detect_loops(TEE_INSTANCE *instance, HASHTABLE* ht, SERVICE* service)
}
SERVICE* tgt = ninst->service;
if (detect_loops((TEE_INSTANCE*) svc->filters[i]->filter, ht, tgt))
if (detect_loops(ninst, ht, tgt))
{
return true;
}