diff options
author | José Bollo <jose.bollo@iot.bzh> | 2016-05-22 00:29:22 +0200 |
---|---|---|
committer | José Bollo <jose.bollo@iot.bzh> | 2016-05-22 00:29:22 +0200 |
commit | 457c879ff89bc7f1a8864304974999dba54af9ae (patch) | |
tree | 5d18a69c237fac35896911bda1711a147b05fa98 /include/afb | |
parent | ed4e7e3b0690680d963bc722bc259a424099e7e5 (diff) |
Fix AFB_SESSION_CREATE behaviour
This commit allows to call methods having AFB_SESSION_CREATE
at any time.
This commit prepares the future LOA (level of authorization)
implementation that wille soon replace the deprecated mechanism
of AFB_SESSION_CREATE.
Change-Id: Ia3e99186e012fcd55a6c81a7067ab5b4aca21e4d
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'include/afb')
-rw-r--r-- | include/afb/afb-req-itf.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/include/afb/afb-req-itf.h b/include/afb/afb-req-itf.h index a8980ffc..a3ff9fe0 100644 --- a/include/afb/afb-req-itf.h +++ b/include/afb/afb-req-itf.h @@ -97,6 +97,17 @@ static inline void afb_req_context_set(struct afb_req req, void *value, void (*f return req.itf->context_set(req.closure, value, free_value); } +static inline void *afb_req_context(struct afb_req req, void *(*create_value)(), void (*free_value)(void*)) +{ + void *result = req.itf->context_get(req.closure); + if (result == NULL) { + result = create_value(); + if (result != NULL) + req.itf->context_set(req.closure, result, free_value); + } + return result; +} + static inline void afb_req_context_clear(struct afb_req req) { afb_req_context_set(req, NULL, NULL); |