X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-api-so-v2.c;h=2770f64a29efc5d3c863ef22642311fc803842c2;hb=6797f9722dd3e5463e0f7c118397955bb59a40c7;hp=0c8079c4526a484fa63a2b32856d955a3364cef1;hpb=20ea5089d0e5526afaa5231f30add7b25b2499bd;p=src%2Fapp-framework-binder.git diff --git a/src/afb-api-so-v2.c b/src/afb-api-so-v2.c index 0c8079c4..2770f64a 100644 --- a/src/afb-api-so-v2.c +++ b/src/afb-api-so-v2.c @@ -31,6 +31,7 @@ #include "afb-context.h" #include "afb-api-so.h" #include "afb-thread.h" +#include "afb-xreq.h" #include "verbose.h" /* @@ -171,21 +172,46 @@ static int call_check(struct afb_req req, struct afb_context *context, const str return 1; } -static void call_cb(void *closure, struct afb_req req, struct afb_context *context, const char *strverb) +static const struct afb_verb_v2 *search(struct api_so_v2 *desc, const char *verb) +{ + const struct afb_verb_v2 *result; + + result = desc->binding->verbs; + while (result->verb && strcasecmp(result->verb, verb)) + result++; + return result->verb ? result : NULL; +} + +static void call_cb(void *closure, struct afb_req req, struct afb_context *context, const char *name) { - const struct afb_verb_v2 *verb; struct api_so_v2 *desc = closure; + const struct afb_verb_v2 *verb; - verb = desc->binding->verbs; - while (verb->verb && strcasecmp(verb->verb, strverb)) - verb++; - if (!verb->verb) - afb_req_fail_f(req, "unknown-verb", "verb %s unknown within api %s", strverb, desc->binding->api); + verb = search(desc, name); + if (!verb) + afb_req_fail_f(req, "unknown-verb", "verb %s unknown within api %s", name, desc->binding->api); else if (call_check(req, context, verb)) { afb_thread_req_call(req, verb->callback, afb_api_so_timeout, desc); } } +static void xcall_cb(void *closure, struct afb_xreq *xreq) +{ + struct api_so_v2 *desc = closure; + const struct afb_verb_v2 *verb; + + verb = search(desc, xreq->verb); + if (!verb) + afb_xreq_fail_f(xreq, "unknown-verb", "verb %s unknown within api %s", xreq->verb, desc->binding->api); + else { + xreq->timeout = afb_api_so_timeout; + xreq->sessionflags = (int)verb->session; + xreq->group = desc; + xreq->callback = verb->callback; + afb_xreq_call(xreq); + } +} + static int service_start_cb(void *closure, int share_session, int onneed) { int (*start)(const struct afb_binding_interface *interface, struct afb_service service); @@ -291,6 +317,7 @@ int afb_api_so_v2_add(const char *path, void *handle) if (afb_apis_add(binding->api, (struct afb_api){ .closure = desc, .call = call_cb, + .xcall = xcall_cb, .service_start = service_start_cb }) < 0) { ERROR("binding [%s] can't be registered...", path); goto error2;