X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-api-so-v1.c;h=3eea464597b0bfc0235c7c66d74ab4a288f903c5;hb=11e2d4395056c7bd2a618b4fa7ffdd70af05d14e;hp=7e987c22aca39c1a1aacdcdf1b8e32fa5e2a64a0;hpb=bfffa28ba0483b49770326c4f567950ea80d0fb6;p=src%2Fapp-framework-binder.git diff --git a/src/afb-api-so-v1.c b/src/afb-api-so-v1.c index 7e987c22..3eea4645 100644 --- a/src/afb-api-so-v1.c +++ b/src/afb-api-so-v1.c @@ -78,6 +78,7 @@ static void call_cb(void *closure, struct afb_xreq *xreq) static int service_start_cb(void *closure, int share_session, int onneed, struct afb_apiset *apiset) { + int rc; int (*init)(struct afb_service service); void (*onevent)(const char *event, struct json_object *object); @@ -108,13 +109,22 @@ static int service_start_cb(void *closure, int share_session, int onneed, struct } /* get the event handler if any */ - desc->service = afb_svc_create_v1(desc->binding->v1.prefix, apiset, share_session, init, onevent); + desc->service = afb_svc_create(desc->binding->v1.prefix, apiset, share_session, onevent, NULL); if (desc->service == NULL) { - /* starting error */ - ERROR("Starting service %s failed", desc->binding->v1.prefix); + ERROR("Creation of service %s failed", desc->binding->v1.prefix); return -1; } + /* Starts the service */ + rc = afb_svc_start_v1(desc->service, init); + if (rc < 0) { + /* initialisation error */ + ERROR("Initialisation of service %s failed (%d): %m", desc->binding->v1.prefix, rc); + afb_svc_destroy(desc->service, NULL); + desc->service = NULL; + return rc; + } + return 0; }