X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-api-dyn.c;h=2ef1b1a5686323d834c90f6bc074215a316883e0;hb=afff776f7e27c8be7610cfbd23c4d1be32699ed9;hp=880221095d3d04bfb81d1800df50608c27e25854;hpb=59cd34b59853f6a47e756d7ab5bc0329f40a471c;p=src%2Fapp-framework-binder.git diff --git a/src/afb-api-dyn.c b/src/afb-api-dyn.c index 88022109..2ef1b1a5 100644 --- a/src/afb-api-dyn.c +++ b/src/afb-api-dyn.c @@ -58,11 +58,14 @@ int afb_api_dyn_add_verb( const char *verb, const char *info, void (*callback)(struct afb_request *request), + void *vcbdata, const struct afb_auth *auth, uint32_t session) { struct afb_api_dyn_verb *v, **vv; + afb_api_dyn_sub_verb(dynapi, verb); + vv = realloc(dynapi->verbs, (1 + dynapi->count) * sizeof *vv); if (!vv) goto oom; @@ -73,6 +76,7 @@ int afb_api_dyn_add_verb( goto oom; v->callback = callback; + v->vcbdata = vcbdata; v->auth = auth; v->session = session; @@ -114,19 +118,21 @@ int afb_api_dyn_sub_verb( static void call_cb(void *closure, struct afb_xreq *xreq) { struct afb_api_dyn *dynapi = closure; - struct afb_api_dyn_verb **verbs; + struct afb_api_dyn_verb **verbs, *v; const struct afb_verb_v2 *verbsv2; int i; const char *name; - name = xreq->verb; + name = xreq->request.verb; xreq->request.dynapi = (void*)dynapi->export; /* hack: this avoids to export afb_export structure */ /* look first in dyna mic verbs */ verbs = dynapi->verbs; i = dynapi->count; while (i) { - if (!strcasecmp(verbs[--i]->verb, name)) { + v = verbs[--i]; + if (!strcasecmp(v->verb, name)) { + xreq->request.vcbdata = v->vcbdata; afb_xreq_call_verb_vdyn(xreq, verbs[i]); return; } @@ -229,7 +235,7 @@ static struct afb_api_itf dyn_api_itf = { .describe = describe_cb }; -int afb_api_dyn_add(struct afb_apiset *apiset, const char *name, const char *info, int (*preinit)(void*, struct afb_dynapi*), void *closure) +int afb_api_dyn_add(struct afb_apiset *apiset, const char *name, const char *info, int noconcurrency, int (*preinit)(void*, struct afb_dynapi*), void *closure) { int rc; struct afb_api_dyn *dynapi; @@ -260,7 +266,7 @@ int afb_api_dyn_add(struct afb_apiset *apiset, const char *name, const char *inf /* records the binding */ afb_api.closure = dynapi; afb_api.itf = &dyn_api_itf; - afb_api.group = NULL; + afb_api.group = noconcurrency ? dynapi : NULL; if (afb_apiset_add(apiset, afb_export_apiname(dynapi->export), afb_api) < 0) { ERROR("dynamic api %s can't be registered to set %s, ABORTING it!", afb_export_apiname(dynapi->export), @@ -268,7 +274,7 @@ int afb_api_dyn_add(struct afb_apiset *apiset, const char *name, const char *inf goto error; } INFO("binding %s added to set %s", afb_export_apiname(dynapi->export), afb_apiset_name(apiset)); - return 1; + return 0; error: afb_export_destroy(export);