MXS-936: destroyInstance added for filters
MXS-936: destroyInstance added for filters
This commit is contained in:
@ -83,6 +83,7 @@ typedef struct filter_object
|
|||||||
int (*clientReply)(FILTER *instance, void *fsession, GWBUF *queue);
|
int (*clientReply)(FILTER *instance, void *fsession, GWBUF *queue);
|
||||||
void (*diagnostics)(FILTER *instance, void *fsession, DCB *dcb);
|
void (*diagnostics)(FILTER *instance, void *fsession, DCB *dcb);
|
||||||
uint64_t (*getCapabilities)(void);
|
uint64_t (*getCapabilities)(void);
|
||||||
|
void (*destroyInstance)(FILTER *instance);
|
||||||
} FILTER_OBJECT;
|
} FILTER_OBJECT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1833,6 +1833,18 @@ void service_shutdown()
|
|||||||
{
|
{
|
||||||
svc->router->destroyInstance(svc->router_instance);
|
svc->router->destroyInstance(svc->router_instance);
|
||||||
}
|
}
|
||||||
|
if (svc->n_filters)
|
||||||
|
{
|
||||||
|
FILTER_DEF **filters = svc->filters;
|
||||||
|
for (int i=0; i < svc->n_filters; i++)
|
||||||
|
{
|
||||||
|
if (filters[i]->obj->destroyInstance)
|
||||||
|
{
|
||||||
|
/* Call destroyInstance hook for filters */
|
||||||
|
filters[i]->obj->destroyInstance(filters[i]->filter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
svc = svc->next;
|
svc = svc->next;
|
||||||
}
|
}
|
||||||
spinlock_release(&service_spin);
|
spinlock_release(&service_spin);
|
||||||
|
3
server/modules/filter/cache/cache.c
vendored
3
server/modules/filter/cache/cache.c
vendored
@ -80,7 +80,8 @@ FILTER_OBJECT *GetModuleObject()
|
|||||||
routeQuery,
|
routeQuery,
|
||||||
clientReply,
|
clientReply,
|
||||||
diagnostics,
|
diagnostics,
|
||||||
getCapabilities
|
getCapabilities,
|
||||||
|
NULL, // destroyInstance
|
||||||
};
|
};
|
||||||
|
|
||||||
return &object;
|
return &object;
|
||||||
|
@ -75,9 +75,10 @@ static FILTER_OBJECT MyObject =
|
|||||||
setDownstream,
|
setDownstream,
|
||||||
NULL, // No Upstream requirement
|
NULL, // No Upstream requirement
|
||||||
routeQuery,
|
routeQuery,
|
||||||
NULL,
|
NULL, // No clientReply
|
||||||
diagnostic,
|
diagnostic,
|
||||||
getCapabilities,
|
getCapabilities,
|
||||||
|
NULL, // No destroyInstance
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CCR_DEFAULT_TIME 60
|
#define CCR_DEFAULT_TIME 60
|
||||||
|
@ -114,11 +114,12 @@ static FILTER_OBJECT MyObject =
|
|||||||
closeSession,
|
closeSession,
|
||||||
freeSession,
|
freeSession,
|
||||||
setDownstream,
|
setDownstream,
|
||||||
NULL,
|
NULL, // No setUpStream
|
||||||
routeQuery,
|
routeQuery,
|
||||||
NULL,
|
NULL, // No clientReply
|
||||||
diagnostic,
|
diagnostic,
|
||||||
getCapabilities,
|
getCapabilities,
|
||||||
|
NULL, // No destroyInstance
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -103,9 +103,10 @@ static FILTER_OBJECT MyObject =
|
|||||||
setDownstream,
|
setDownstream,
|
||||||
NULL, // No upstream requirement
|
NULL, // No upstream requirement
|
||||||
routeQuery,
|
routeQuery,
|
||||||
NULL,
|
NULL, // No clientReply
|
||||||
diagnostic,
|
diagnostic,
|
||||||
getCapabilities,
|
getCapabilities,
|
||||||
|
NULL, // No destroyInstance
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,9 +52,10 @@ static FILTER_OBJECT MyObject =
|
|||||||
setDownstream,
|
setDownstream,
|
||||||
NULL, // No upstream requirement
|
NULL, // No upstream requirement
|
||||||
routeQuery,
|
routeQuery,
|
||||||
NULL,
|
NULL, // No clientReply
|
||||||
diagnostic,
|
diagnostic,
|
||||||
getCapabilities,
|
getCapabilities,
|
||||||
|
NULL, // No destroyInstance
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -96,6 +96,7 @@ static FILTER_OBJECT MyObject =
|
|||||||
clientReply,
|
clientReply,
|
||||||
diagnostic,
|
diagnostic,
|
||||||
getCapabilities,
|
getCapabilities,
|
||||||
|
NULL, // No destroyInstance
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -98,7 +98,8 @@ FILTER_OBJECT *GetModuleObject()
|
|||||||
routeQuery,
|
routeQuery,
|
||||||
clientReply,
|
clientReply,
|
||||||
diagnostics,
|
diagnostics,
|
||||||
getCapabilities
|
getCapabilities,
|
||||||
|
NULL, // No destroyInstance
|
||||||
};
|
};
|
||||||
|
|
||||||
return &object;
|
return &object;
|
||||||
@ -917,4 +918,3 @@ static int send_ok_upstream(MAXROWS_SESSION_DATA *csdata)
|
|||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,6 +116,7 @@ static FILTER_OBJECT MyObject =
|
|||||||
clientReply,
|
clientReply,
|
||||||
diagnostic,
|
diagnostic,
|
||||||
getCapabilities,
|
getCapabilities,
|
||||||
|
NULL, // No destroyInstance
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -69,9 +69,10 @@ static FILTER_OBJECT MyObject =
|
|||||||
setDownstream,
|
setDownstream,
|
||||||
NULL, // No Upstream requirement
|
NULL, // No Upstream requirement
|
||||||
routeQuery,
|
routeQuery,
|
||||||
NULL,
|
NULL, // No clientReply
|
||||||
diagnostic,
|
diagnostic,
|
||||||
getCapabilities,
|
getCapabilities,
|
||||||
|
NULL, // No destroyInstance
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -87,6 +87,7 @@ static FILTER_OBJECT MyObject =
|
|||||||
NULL, // No client reply
|
NULL, // No client reply
|
||||||
diagnostic,
|
diagnostic,
|
||||||
getCapabilities,
|
getCapabilities,
|
||||||
|
NULL, // No destroyInstance
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -71,9 +71,10 @@ static FILTER_OBJECT MyObject =
|
|||||||
setDownstream,
|
setDownstream,
|
||||||
NULL, // No Upstream requirement
|
NULL, // No Upstream requirement
|
||||||
routeQuery,
|
routeQuery,
|
||||||
NULL,
|
NULL, // No clientReply
|
||||||
diagnostic,
|
diagnostic,
|
||||||
getCapabilities,
|
getCapabilities,
|
||||||
|
NULL, // No destroyInstance
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,6 +130,7 @@ static FILTER_OBJECT MyObject =
|
|||||||
clientReply,
|
clientReply,
|
||||||
diagnostic,
|
diagnostic,
|
||||||
getCapabilities,
|
getCapabilities,
|
||||||
|
NULL, // No destroyInstance
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,7 +37,7 @@ MODULE_INFO info =
|
|||||||
"A simple query counting filter"
|
"A simple query counting filter"
|
||||||
};
|
};
|
||||||
|
|
||||||
static char *version_str = "V1.0.0";
|
static char *version_str = "V2.0.0";
|
||||||
|
|
||||||
static FILTER *createInstance(const char *name, char **options, FILTER_PARAMETER **params);
|
static FILTER *createInstance(const char *name, char **options, FILTER_PARAMETER **params);
|
||||||
static void *newSession(FILTER *instance, SESSION *session);
|
static void *newSession(FILTER *instance, SESSION *session);
|
||||||
@ -47,6 +47,7 @@ static void setDownstream(FILTER *instance, void *fsession, DOWNSTREAM *down
|
|||||||
static int routeQuery(FILTER *instance, void *fsession, GWBUF *queue);
|
static int routeQuery(FILTER *instance, void *fsession, GWBUF *queue);
|
||||||
static void diagnostic(FILTER *instance, void *fsession, DCB *dcb);
|
static void diagnostic(FILTER *instance, void *fsession, DCB *dcb);
|
||||||
static uint64_t getCapabilities(void);
|
static uint64_t getCapabilities(void);
|
||||||
|
static void destroyInstance(FILTER *instance);
|
||||||
|
|
||||||
|
|
||||||
static FILTER_OBJECT MyObject =
|
static FILTER_OBJECT MyObject =
|
||||||
@ -58,9 +59,10 @@ static FILTER_OBJECT MyObject =
|
|||||||
setDownstream,
|
setDownstream,
|
||||||
NULL, // No upstream requirement
|
NULL, // No upstream requirement
|
||||||
routeQuery,
|
routeQuery,
|
||||||
NULL,
|
NULL, // No clientReply
|
||||||
diagnostic,
|
diagnostic,
|
||||||
getCapabilities,
|
getCapabilities,
|
||||||
|
destroyInstance,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,6 +70,7 @@ static FILTER_OBJECT MyObject =
|
|||||||
*/
|
*/
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
const char *name;
|
||||||
int sessions;
|
int sessions;
|
||||||
} TEST_INSTANCE;
|
} TEST_INSTANCE;
|
||||||
|
|
||||||
@ -135,6 +138,7 @@ createInstance(const char *name, char **options, FILTER_PARAMETER **params)
|
|||||||
if ((my_instance = MXS_CALLOC(1, sizeof(TEST_INSTANCE))) != NULL)
|
if ((my_instance = MXS_CALLOC(1, sizeof(TEST_INSTANCE))) != NULL)
|
||||||
{
|
{
|
||||||
my_instance->sessions = 0;
|
my_instance->sessions = 0;
|
||||||
|
my_instance->name = name;
|
||||||
}
|
}
|
||||||
return (FILTER *)my_instance;
|
return (FILTER *)my_instance;
|
||||||
}
|
}
|
||||||
@ -258,3 +262,15 @@ static uint64_t getCapabilities(void)
|
|||||||
{
|
{
|
||||||
return RCAP_TYPE_NONE;
|
return RCAP_TYPE_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* destroyInstance routine.
|
||||||
|
*
|
||||||
|
* @param The filter instance.
|
||||||
|
*/
|
||||||
|
static void destroyInstance(FILTER *instance)
|
||||||
|
{
|
||||||
|
TEST_INSTANCE *cinstance = (TEST_INSTANCE *)instance;
|
||||||
|
|
||||||
|
MXS_INFO("Destroying filter %s", cinstance->name);
|
||||||
|
}
|
||||||
|
@ -82,6 +82,7 @@ static FILTER_OBJECT MyObject =
|
|||||||
clientReply,
|
clientReply,
|
||||||
diagnostic,
|
diagnostic,
|
||||||
getCapabilities,
|
getCapabilities,
|
||||||
|
NULL, // No destroyInstance
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,6 +95,7 @@ static FILTER_OBJECT MyObject =
|
|||||||
clientReply,
|
clientReply,
|
||||||
diagnostic,
|
diagnostic,
|
||||||
getCapabilities,
|
getCapabilities,
|
||||||
|
NULL, // No destroyInstance
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user