Add service capabilities

The service capabilities are the union of the capabilities of the
router and all filters.
This commit is contained in:
Johan Wikman 2016-10-21 14:36:36 +03:00
parent 3915b4e7c7
commit bd18a7d8ed
2 changed files with 22 additions and 1 deletions

View File

@ -167,6 +167,7 @@ typedef struct service
struct service *next; /**< The next service in the linked list */
bool retry_start; /*< If starting of the service should be retried later */
bool log_auth_warnings; /*< Log authentication failures and warnings */
uint64_t capabilities; /*< The capabilities of the service. */
} SERVICE;
typedef enum count_spec_t
@ -237,6 +238,19 @@ extern RESULTSET *serviceGetList();
extern RESULTSET *serviceGetListenerList();
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
#endif

View File

@ -143,6 +143,7 @@ service_alloc(const char *servname, const char *router)
return NULL;
}
service->capabilities = service->router->getCapabilities();
service->client_count = 0;
service->name = (char*)servname;
service->routerModule = (char*)router;
@ -1066,6 +1067,7 @@ serviceSetFilters(SERVICE *service, char *filters)
char *ptr, *brkt;
int n = 0;
bool rval = true;
uint64_t capabilities = 0;
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 (!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'.",
filter_name, service->name);
@ -1112,6 +1118,7 @@ serviceSetFilters(SERVICE *service, char *filters)
{
service->filters = flist;
service->n_filters = n;
service->capabilities |= capabilities;
}
else
{