Add service capabilities
The service capabilities are the union of the capabilities of the router and all filters.
This commit is contained in:
@ -167,6 +167,7 @@ typedef struct service
|
|||||||
struct service *next; /**< The next service in the linked list */
|
struct service *next; /**< The next service in the linked list */
|
||||||
bool retry_start; /*< If starting of the service should be retried later */
|
bool retry_start; /*< If starting of the service should be retried later */
|
||||||
bool log_auth_warnings; /*< Log authentication failures and warnings */
|
bool log_auth_warnings; /*< Log authentication failures and warnings */
|
||||||
|
uint64_t capabilities; /*< The capabilities of the service. */
|
||||||
} SERVICE;
|
} SERVICE;
|
||||||
|
|
||||||
typedef enum count_spec_t
|
typedef enum count_spec_t
|
||||||
@ -237,6 +238,19 @@ extern RESULTSET *serviceGetList();
|
|||||||
extern RESULTSET *serviceGetListenerList();
|
extern RESULTSET *serviceGetListenerList();
|
||||||
extern bool service_all_services_have_listeners();
|
extern bool service_all_services_have_listeners();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the capabilities of the servive.
|
||||||
|
*
|
||||||
|
* The capabilities of a service are the union of the capabilities of
|
||||||
|
* its router and all filters.
|
||||||
|
*
|
||||||
|
* @return The service capabilities.
|
||||||
|
*/
|
||||||
|
static inline uint64_t service_get_capabilities(const SERVICE *service)
|
||||||
|
{
|
||||||
|
return service->capabilities;
|
||||||
|
}
|
||||||
|
|
||||||
MXS_END_DECLS
|
MXS_END_DECLS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -143,6 +143,7 @@ service_alloc(const char *servname, const char *router)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
service->capabilities = service->router->getCapabilities();
|
||||||
service->client_count = 0;
|
service->client_count = 0;
|
||||||
service->name = (char*)servname;
|
service->name = (char*)servname;
|
||||||
service->routerModule = (char*)router;
|
service->routerModule = (char*)router;
|
||||||
@ -1066,6 +1067,7 @@ serviceSetFilters(SERVICE *service, char *filters)
|
|||||||
char *ptr, *brkt;
|
char *ptr, *brkt;
|
||||||
int n = 0;
|
int n = 0;
|
||||||
bool rval = true;
|
bool rval = true;
|
||||||
|
uint64_t capabilities = 0;
|
||||||
|
|
||||||
if ((flist = (FILTER_DEF **) MXS_MALLOC(sizeof(FILTER_DEF *))) == NULL)
|
if ((flist = (FILTER_DEF **) MXS_MALLOC(sizeof(FILTER_DEF *))) == NULL)
|
||||||
{
|
{
|
||||||
@ -1088,7 +1090,11 @@ serviceSetFilters(SERVICE *service, char *filters)
|
|||||||
|
|
||||||
if ((flist[n - 1] = filter_find(filter_name)))
|
if ((flist[n - 1] = filter_find(filter_name)))
|
||||||
{
|
{
|
||||||
if (!filter_load(flist[n - 1]))
|
if (filter_load(flist[n - 1]))
|
||||||
|
{
|
||||||
|
capabilities |= flist[n - 1]->obj->getCapabilities();
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
MXS_ERROR("Failed to load filter '%s' for service '%s'.",
|
MXS_ERROR("Failed to load filter '%s' for service '%s'.",
|
||||||
filter_name, service->name);
|
filter_name, service->name);
|
||||||
@ -1112,6 +1118,7 @@ serviceSetFilters(SERVICE *service, char *filters)
|
|||||||
{
|
{
|
||||||
service->filters = flist;
|
service->filters = flist;
|
||||||
service->n_filters = n;
|
service->n_filters = n;
|
||||||
|
service->capabilities |= capabilities;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user