aboutsummaryrefslogtreecommitdiffstats
path: root/src/afb-xreq.c
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-08-31 18:47:50 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-08-31 18:47:50 +0200
commit2e83db0375d44c0b05742e787f6abd4127e2aac8 (patch)
tree846004a678795804e60627fdc4dd366a64a4e8b0 /src/afb-xreq.c
parent859aa04ec2ee66709261a62d7f002d6a01c97a81 (diff)
afb-apiset: refactor access to apis
Change-Id: If003067ada5802b7d77f06f560a5d07464909a61 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
Diffstat (limited to 'src/afb-xreq.c')
-rw-r--r--src/afb-xreq.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/afb-xreq.c b/src/afb-xreq.c
index 80dd143d..73841af9 100644
--- a/src/afb-xreq.c
+++ b/src/afb-xreq.c
@@ -876,7 +876,7 @@ void afb_xreq_fail_unknown_verb(struct afb_xreq *xreq)
static void process_sync(struct afb_xreq *xreq)
{
- struct afb_api api;
+ const struct afb_api *api;
/* init hooking */
afb_hook_init_xreq(xreq);
@@ -884,14 +884,15 @@ static void process_sync(struct afb_xreq *xreq)
afb_hook_xreq_begin(xreq);
/* search the api */
- if (afb_apiset_get_started(xreq->apiset, xreq->api, &api) < 0) {
+ api = afb_apiset_lookup_started(xreq->apiset, xreq->api, 1);
+ if (!api) {
if (errno == ENOENT)
afb_xreq_fail_f(xreq, "unknown-api", "api %s not found", xreq->api);
else
afb_xreq_fail_f(xreq, "bad-api-state", "api %s not started correctly: %m", xreq->api);
} else {
- xreq->context.api_key = api.closure;
- api.itf->call(api.closure, xreq);
+ xreq->context.api_key = api->closure;
+ api->itf->call(api->closure, xreq);
}
}