The apis starting with a $ (dollar) will not be
tracked by hooks
Change-Id: I3b83458c288ef1eb27993d4c71785b32e5a72deb
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
};
extern int afb_api_is_valid_name(const char *name);
};
extern int afb_api_is_valid_name(const char *name);
+
+#define AFB_API_UNHOOKABLE_PREFIX_CHAR '$'
+#define AFB_API_UNHOOKABLE_PREFIX_STRING "$"
+#define afb_api_is_hookable(api) ((api)[0] != AFB_API_UNHOOKABLE_PREFIX_CHAR)
+
#include "afb-xreq.h"
#include "afb-export.h"
#include "afb-evt.h"
#include "afb-xreq.h"
#include "afb-export.h"
#include "afb-evt.h"
/* scan hook list to get the expected flags */
flags = 0;
/* scan hook list to get the expected flags */
flags = 0;
- pthread_rwlock_rdlock(&rwlock);
- hook = list_of_xreq_hooks;
- while (hook) {
- f = hook->flags & afb_hook_flags_req_all;
- add = f != 0
- && (!hook->session || hook->session == xreq->context.session)
- && (!hook->api || !strcasecmp(hook->api, xreq->request.api))
- && (!hook->verb || !strcasecmp(hook->verb, xreq->request.verb));
- if (add)
- flags |= f;
- hook = hook->next;
+ if (afb_api_is_hookable(xreq->request.api)) {
+ pthread_rwlock_rdlock(&rwlock);
+ hook = list_of_xreq_hooks;
+ while (hook) {
+ f = hook->flags & afb_hook_flags_req_all;
+ add = f != 0
+ && (!hook->session || hook->session == xreq->context.session)
+ && (!hook->api || !strcasecmp(hook->api, xreq->request.api))
+ && (!hook->verb || !strcasecmp(hook->verb, xreq->request.verb));
+ if (add)
+ flags |= f;
+ hook = hook->next;
+ }
+ pthread_rwlock_unlock(&rwlock);
- pthread_rwlock_unlock(&rwlock);
/* store the hooking data */
xreq->hookflags = flags;
/* store the hooking data */
xreq->hookflags = flags;
int flags;
struct afb_hook_ditf *hook;
int flags;
struct afb_hook_ditf *hook;
- pthread_rwlock_rdlock(&rwlock);
- hook = list_of_ditf_hooks;
- while (hook) {
- if (!api || !hook->api || !strcasecmp(hook->api, api))
- flags |= hook->flags;
- hook = hook->next;
+ if (!api || afb_api_is_hookable(api)) {
+ pthread_rwlock_rdlock(&rwlock);
+ hook = list_of_ditf_hooks;
+ while (hook) {
+ if (!api || !hook->api || !strcasecmp(hook->api, api))
+ flags |= hook->flags;
+ hook = hook->next;
+ }
+ pthread_rwlock_unlock(&rwlock);
- pthread_rwlock_unlock(&rwlock);
int flags;
struct afb_hook_svc *hook;
int flags;
struct afb_hook_svc *hook;
- pthread_rwlock_rdlock(&rwlock);
- hook = list_of_svc_hooks;
- while (hook) {
- if (!api || !hook->api || !strcasecmp(hook->api, api))
- flags |= hook->flags;
- hook = hook->next;
+ if (!api || afb_api_is_hookable(api)) {
+ pthread_rwlock_rdlock(&rwlock);
+ hook = list_of_svc_hooks;
+ while (hook) {
+ if (!api || !hook->api || !strcasecmp(hook->api, api))
+ flags |= hook->flags;
+ hook = hook->next;
+ }
+ pthread_rwlock_unlock(&rwlock);
- pthread_rwlock_unlock(&rwlock);
int flags;
struct afb_hook_evt *hook;
int flags;
struct afb_hook_evt *hook;
- pthread_rwlock_rdlock(&rwlock);
- hook = list_of_evt_hooks;
- while (hook) {
- if (!name || !hook->pattern || !fnmatch(hook->pattern, name, FNM_CASEFOLD))
- flags |= hook->flags;
- hook = hook->next;
+ if (!name || afb_api_is_hookable(name)) {
+ pthread_rwlock_rdlock(&rwlock);
+ hook = list_of_evt_hooks;
+ while (hook) {
+ if (!name || !hook->pattern || !fnmatch(hook->pattern, name, FNM_CASEFOLD))
+ flags |= hook->flags;
+ hook = hook->next;
+ }
+ pthread_rwlock_unlock(&rwlock);
- pthread_rwlock_unlock(&rwlock);