Remove filter options

None of the filters used the options. The filter API version was already
incremented once for 2.3 so there's no need to increment it again.
This commit is contained in:
Markus Mäkelä
2018-07-10 06:05:50 +03:00
parent cbb8c68770
commit 81527894ee
41 changed files with 50 additions and 158 deletions

View File

@ -3689,17 +3689,6 @@ int create_new_filter(CONFIG_CONTEXT *obj)
if ((obj->element = filter_alloc(obj->object, module)))
{
MXS_FILTER_DEF* filter_def = (MXS_FILTER_DEF*)obj->element;
char *options = config_get_value(obj->parameters, CN_OPTIONS);
if (options)
{
char *lasts;
char *s = strtok_r(options, ",", &lasts);
while (s)
{
filter_add_option(filter_def, s);
s = strtok_r(NULL, ",", &lasts);
}
}
const MXS_MODULE *mod = get_module(module, MODULE_FILTER);

View File

@ -70,7 +70,6 @@ filter_alloc(const char *name, const char *module)
filter->name = my_name;
filter->module = my_module;
filter->filter = NULL;
filter->options = NULL;
filter->obj = NULL;
filter->parameters = NULL;
@ -122,15 +121,6 @@ filter_free(MXS_FILTER_DEF *filter)
MXS_FREE(filter->name);
MXS_FREE(filter->module);
if (filter->options)
{
for (int i = 0; filter->options[i]; i++)
{
MXS_FREE(filter->options[i]);
}
MXS_FREE(filter->options);
}
filter_free_parameters(filter);
MXS_FREE(filter);
@ -204,15 +194,6 @@ dprintAllFilters(DCB *dcb)
{
dcb_printf(dcb, "Filter %p (%s)\n", ptr, ptr->name);
dcb_printf(dcb, "\tModule: %s\n", ptr->module);
if (ptr->options)
{
dcb_printf(dcb, "\tOptions: ");
for (i = 0; ptr->options && ptr->options[i]; i++)
{
dcb_printf(dcb, "%s ", ptr->options[i]);
}
dcb_printf(dcb, "\n");
}
if (ptr->obj && ptr->filter)
{
ptr->obj->diagnostics(ptr->filter, NULL, dcb);
@ -239,15 +220,6 @@ dprintFilter(DCB *dcb, const MXS_FILTER_DEF *filter)
dcb_printf(dcb, "Filter %p (%s)\n", filter, filter->name);
dcb_printf(dcb, "\tModule: %s\n", filter->module);
if (filter->options)
{
dcb_printf(dcb, "\tOptions: ");
for (i = 0; filter->options && filter->options[i]; i++)
{
dcb_printf(dcb, "%s ", filter->options[i]);
}
dcb_printf(dcb, "\n");
}
if (filter->obj && filter->filter)
{
filter->obj->diagnostics(filter->filter, NULL, dcb);
@ -278,10 +250,6 @@ dListFilters(DCB *dcb)
{
dcb_printf(dcb, "%-19s | %-15s | ",
ptr->name, ptr->module);
for (i = 0; ptr->options && ptr->options[i]; i++)
{
dcb_printf(dcb, "%s ", ptr->options[i]);
}
dcb_printf(dcb, "\n");
ptr = ptr->next;
}
@ -293,41 +261,6 @@ dListFilters(DCB *dcb)
spinlock_release(&filter_spin);
}
/**
* Add a router option to a service
*
* @param filter The filter to add the option to
* @param option The option string
*/
void
filter_add_option(MXS_FILTER_DEF *filter, const char *option)
{
int i;
spinlock_acquire(&filter->spin);
if (filter->options == NULL)
{
filter->options = (char **)MXS_CALLOC(2, sizeof(char *));
MXS_ABORT_IF_NULL(filter->options);
filter->options[0] = MXS_STRDUP_A(option);
filter->options[1] = NULL;
}
else
{
for (i = 0; filter->options[i]; i++)
{
;
}
filter->options = (char **)MXS_REALLOC(filter->options, (i + 2) * sizeof(char *));
MXS_ABORT_IF_NULL(filter->options);
filter->options[i] = MXS_STRDUP_A(option);
MXS_ABORT_IF_NULL(filter->options[i]);
filter->options[i + 1] = NULL;
}
spinlock_release(&filter->spin);
}
/**
* Add a router parameter to a service
*
@ -386,7 +319,6 @@ bool filter_load(MXS_FILTER_DEF* filter)
ss_dassert(!filter->filter);
if ((filter->filter = (filter->obj->createInstance)(filter->name,
filter->options,
filter->parameters)))
{
rval = true;
@ -479,18 +411,6 @@ json_t* filter_parameters_to_json(const MXS_FILTER_DEF* filter)
{
json_t* rval = json_object();
if (filter->options)
{
json_t* arr = json_array();
for (int i = 0; filter->options && filter->options[i]; i++)
{
json_array_append_new(arr, json_string(filter->options[i]));
}
json_object_set_new(rval, "options", arr);
}
/** Add custom module parameters */
const MXS_MODULE* mod = get_module(filter->module, MODULE_FILTER);
config_add_module_params_json(mod, filter->parameters, config_filter_params, rval);

View File

@ -29,7 +29,6 @@ struct mxs_filter_def
{
char *name; /**< The Filter name */
char *module; /**< The module to load */
char **options; /**< The options set for this filter */
MXS_CONFIG_PARAMETER *parameters; /**< The filter parameters */
MXS_FILTER* filter; /**< The runtime filter */
MXS_FILTER_OBJECT *obj; /**< The "MODULE_OBJECT" for the filter */
@ -37,7 +36,6 @@ struct mxs_filter_def
struct mxs_filter_def *next; /**< Next filter in the chain of all filters */
};
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);
MXS_DOWNSTREAM *filter_apply(MXS_FILTER_DEF *filter_def, MXS_SESSION *session, MXS_DOWNSTREAM *downstream);

View File

@ -83,9 +83,6 @@ test2()
fprintf(stderr, "filter_alloc: test 1 failed.\n");
return 1;
}
filter_add_option(f1, "option1");
filter_add_option(f1, "option2");
filter_add_option(f1, "option3");
filter_add_parameter(f1, "name1", "value1");
filter_add_parameter(f1, "name2", "value2");
filter_add_parameter(f1, "name3", "value3");