MXS-1929: Initialize filter in filter_alloc

Changed the filter_alloc function to fully initialize the filter. This
means that if filter_alloc returns a non-NULL pointer, the filter was
successfully loaded and an instance was successfully created.
This commit is contained in:
Markus Mäkelä
2018-07-24 08:39:57 +03:00
parent 382595a2b8
commit cea36dc7be
4 changed files with 32 additions and 65 deletions

View File

@ -33,6 +33,9 @@
#include <stdlib.h>
#include <string.h>
#include <maxscale/alloc.h>
#include <maxscale/paths.h>
#include "../internal/filter.h"
@ -45,7 +48,7 @@ test1()
{
MXS_FILTER_DEF *f1, *f2;
if ((f1 = filter_alloc("test1", "module", NULL)) == NULL)
if ((f1 = filter_alloc("test1", "qlafilter", NULL)) == NULL)
{
fprintf(stderr, "filter_alloc: test 1 failed.\n");
return 1;
@ -78,7 +81,7 @@ test2()
{
MXS_FILTER_DEF *f1;
if ((f1 = filter_alloc("test1", "module", NULL)) == NULL)
if ((f1 = filter_alloc("test1", "qlafilter", NULL)) == NULL)
{
fprintf(stderr, "filter_alloc: test 1 failed.\n");
return 1;
@ -106,7 +109,7 @@ test3()
for (i = 0; i < n_filters; i++)
{
sprintf(name, "filter%d", i);
if ((f1 = filter_alloc(name, "module", NULL)) == NULL)
if ((f1 = filter_alloc(name, "qlafilter", NULL)) == NULL)
{
fprintf(stderr,
"filter_alloc: test 3 failed with %s.\n", name);
@ -146,6 +149,7 @@ int
main(int argc, char **argv)
{
int result = 0;
set_libdir(MXS_STRDUP_A("../../modules/filter/qlafilter/"));
result += test1();
result += test2();