diff options
-rw-r--r-- | src/afb-api-so-v1.c | 6 | ||||
-rw-r--r-- | src/afb-api-so-v2.c | 6 | ||||
-rw-r--r-- | src/afb-xreq.c | 33 | ||||
-rw-r--r-- | src/afb-xreq.h | 8 |
4 files changed, 18 insertions, 35 deletions
diff --git a/src/afb-api-so-v1.c b/src/afb-api-so-v1.c index a81ec17c..eedfc010 100644 --- a/src/afb-api-so-v1.c +++ b/src/afb-api-so-v1.c @@ -70,11 +70,7 @@ static void call_cb(void *closure, struct afb_xreq *xreq) struct api_so_v1 *desc = closure; verb = search(desc, xreq->verb); - if (!verb) - afb_xreq_fail_unknown_verb(xreq); - else - if (!xreq_session_check_apply(xreq, verb->session)) - afb_xreq_call(xreq, verb->callback); + afb_xreq_call_verb_v1(xreq, verb); } static int service_start_cb(void *closure, int share_session, int onneed, struct afb_apiset *apiset) diff --git a/src/afb-api-so-v2.c b/src/afb-api-so-v2.c index 12074746..092fd31a 100644 --- a/src/afb-api-so-v2.c +++ b/src/afb-api-so-v2.c @@ -89,11 +89,7 @@ static void call_cb(void *closure, struct afb_xreq *xreq) const struct afb_verb_v2 *verb; verb = search(desc, xreq->verb); - if (!verb) - afb_xreq_fail_unknown_verb(xreq); - else - if (!xreq_session_check_apply(xreq, verb->session)) - afb_xreq_call(xreq, verb->callback); + afb_xreq_call_verb_v2(xreq, verb); } static int service_start_cb(void *closure, int share_session, int onneed, struct afb_apiset *apiset) diff --git a/src/afb-xreq.c b/src/afb-xreq.c index 143048c2..d6cf91fd 100644 --- a/src/afb-xreq.c +++ b/src/afb-xreq.c @@ -439,7 +439,7 @@ void afb_xreq_subcall(struct afb_xreq *xreq, const char *api, const char *verb, afb_req_subcall(to_req(xreq), api, verb, args, callback, cb_closure); } -int xreq_session_check(struct afb_xreq *xreq, int sessionflags) +static int xreq_session_check_apply(struct afb_xreq *xreq, int sessionflags) { int loa; @@ -470,11 +470,6 @@ int xreq_session_check(struct afb_xreq *xreq, int sessionflags) } } - return 0; -} - -void xreq_session_apply(struct afb_xreq *xreq, int sessionflags) -{ if ((sessionflags & AFB_SESSION_RENEW) != 0) { afb_context_refresh(&xreq->context); } @@ -482,26 +477,26 @@ void xreq_session_apply(struct afb_xreq *xreq, int sessionflags) afb_context_change_loa(&xreq->context, 0); afb_context_close(&xreq->context); } -} -int xreq_session_check_apply(struct afb_xreq *xreq, int sessionflags) -{ - int rc = xreq_session_check(xreq, sessionflags); - if (!rc) - xreq_session_apply(xreq, sessionflags); - - return rc; + return 0; } -void afb_xreq_call(struct afb_xreq *xreq, void (*method)(struct afb_req req)) +void afb_xreq_call_verb_v1(struct afb_xreq *xreq, const struct afb_verb_desc_v1 *verb) { - method(to_req(xreq)); + if (!verb) + afb_xreq_fail_unknown_verb(xreq); + else + if (!xreq_session_check_apply(xreq, verb->session)) + verb->callback(to_req(xreq)); } -void afb_xreq_check_apply_call(struct afb_xreq *xreq, int sessionflags, void (*method)(struct afb_req req)) +void afb_xreq_call_verb_v2(struct afb_xreq *xreq, const struct afb_verb_v2 *verb) { - if (!xreq_session_check_apply(xreq, sessionflags)) - method(to_req(xreq)); + if (!verb) + afb_xreq_fail_unknown_verb(xreq); + else + if (!xreq_session_check_apply(xreq, verb->session)) + verb->callback(to_req(xreq)); } void afb_xreq_init(struct afb_xreq *xreq, const struct afb_xreq_query_itf *queryitf) diff --git a/src/afb-xreq.h b/src/afb-xreq.h index a7b086bb..7327c222 100644 --- a/src/afb-xreq.h +++ b/src/afb-xreq.h @@ -124,10 +124,6 @@ extern void afb_xreq_init(struct afb_xreq *xreq, const struct afb_xreq_query_itf extern void afb_xreq_process(struct afb_xreq *xreq, struct afb_apiset *apiset); -extern int xreq_session_check(struct afb_xreq *xreq, int sessionflags); -extern void xreq_session_apply(struct afb_xreq *xreq, int sessionflags); -extern int xreq_session_check_apply(struct afb_xreq *xreq, int sessionflags); - -extern void afb_xreq_call(struct afb_xreq *xreq, void (*callback)(struct afb_req req)); -extern void afb_xreq_check_apply_call(struct afb_xreq *xreq, int sessionflags, void (*callback)(struct afb_req req)); +extern void afb_xreq_call_verb_v1(struct afb_xreq *xreq, const struct afb_verb_desc_v1 *verb); +extern void afb_xreq_call_verb_v2(struct afb_xreq *xreq, const struct afb_verb_v2 *verb); |