X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=blobdiff_plain;f=src%2Fafb-api-so-v3.c;h=66ccb154b0f7339053fe2e5c33fd3ffd83066352;hb=65353dce81a629e042800bb7b86fcd869a76727e;hp=b02f3c8896fdc68d97494c5f8c6275fc96b669ed;hpb=cd6d4492a271951c856ce611b88df0b4cc0ae7f0;p=src%2Fapp-framework-binder.git diff --git a/src/afb-api-so-v3.c b/src/afb-api-so-v3.c index b02f3c88..66ccb154 100644 --- a/src/afb-api-so-v3.c +++ b/src/afb-api-so-v3.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2018 "IoT.bzh" + * Copyright (C) 2015-2020 "IoT.bzh" * Author José Bollo * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,6 +15,8 @@ * limitations under the License. */ +#if WITH_DYNAMIC_BINDING + #define _GNU_SOURCE #include @@ -73,16 +75,16 @@ int afb_api_so_v3_add(const char *path, void *handle, struct afb_apiset *declare struct afb_api_v3 *api; struct afb_export *export; - /* retrieves the register function */ - a.root = dlsym(handle, afb_api_so_v3_root); + /* retrieves important exported symbols */ a.desc = dlsym(handle, afb_api_so_v3_desc); a.entry = dlsym(handle, afb_api_so_v3_entry); - if (!a.root && !a.desc && !a.entry) + if (!a.desc && !a.entry) return 0; INFO("binding [%s] looks like an AFB binding V3", path); /* basic checks */ + a.root = dlsym(handle, afb_api_so_v3_root); if (!a.root) { ERROR("binding [%s] incomplete symbol set: %s is missing", path, afb_api_so_v3_root); @@ -105,7 +107,7 @@ int afb_api_so_v3_add(const char *path, void *handle, struct afb_apiset *declare goto error; } - api = afb_api_v3_create(declare_set, call_set, a.desc->api, a.desc->info, a.desc->noconcurrency, init, &a, 0); + api = afb_api_v3_create(declare_set, call_set, a.desc->api, a.desc->info, a.desc->noconcurrency, init, &a, 0, NULL, path); if (api) return 1; } else { @@ -116,8 +118,17 @@ int afb_api_so_v3_add(const char *path, void *handle, struct afb_apiset *declare } export = afb_export_create_none_for_path(declare_set, call_set, path, init, &a); - if (export) + if (export) { + /* + * No call is done to afb_export_unref(export) because: + * - legacy applications may use the root API emitting messages + * - it allows writting applications like bindings without API + * But this has the sad effect to introduce a kind of leak. + * To avoid this, if necessary further developement should list bindings + * and their data. + */ return 1; + } } ERROR("binding [%s] initialisation failed", path); @@ -126,3 +137,4 @@ error: return -1; } +#endif