X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-apiset.c;h=13d806efcb3cdc564b8fad066192a7ee430bf889;hb=d28921abf7864d580e289873bde3b86ffa19e629;hp=f41c88c00496c0ac49654c6fa7e79991e4b99f10;hpb=9b2c70bf87bb3272cb325f3a9ecf69cd0bd53ba8;p=src%2Fapp-framework-binder.git diff --git a/src/afb-apiset.c b/src/afb-apiset.c index f41c88c0..13d806ef 100644 --- a/src/afb-apiset.c +++ b/src/afb-apiset.c @@ -31,8 +31,6 @@ #include "afb-xreq.h" #include "jobs.h" -#include - #define INCR 8 /* CAUTION: must be a power of 2 */ /** @@ -251,7 +249,7 @@ int afb_apiset_add(struct afb_apiset *set, const char *name, struct afb_api api) apis->name = name; set->count++; - NOTICE("API %s added", name); + INFO("API %s added", name); return 0; @@ -352,6 +350,8 @@ int afb_apiset_get(struct afb_apiset *set, const char *name, struct afb_api *api */ static int start_api(struct afb_apiset *set, struct api_desc *api, int share_session, int onneed) { + int rc; + if (api->status == 0) return 0; else if (api->status > 0) { @@ -359,22 +359,24 @@ static int start_api(struct afb_apiset *set, struct api_desc *api, int share_ses return -1; } + INFO("API %s starting...", api->name); if (api->api.itf->service_start) { api->status = EBUSY; - if (api->api.itf->service_start(api->api.closure, share_session, onneed, set) >= 0) - api->status = 0; - else if (errno) + rc = api->api.itf->service_start(api->api.closure, share_session, onneed, set); + if (rc < 0) { api->status = errno ?: ECANCELED; - } else { - if (onneed) - api->status = 0; - else { - /* already started: it is an error */ - ERROR("The api %s is not a startable service", api->name); - api->status = EINVAL; + ERROR("The api %s failed to start (%d)", api->name, rc); + return -1; } + } else if (!onneed) { + /* already started: it is an error */ + ERROR("The api %s is not a startable service", api->name); + api->status = EINVAL; + return -1; } - return -!!api->status; + NOTICE("API %s started", api->name); + api->status = 0; + return 0; } /**