diff options
author | Adam Michalski <a.michalski2@partner.samsung.com> | 2024-07-04 11:47:59 +0200 |
---|---|---|
committer | Adam Michalski <a.michalski2@partner.samsung.com> | 2024-07-11 14:04:48 +0200 |
commit | 08331ae017c52a1d1ceef5f34f38a90b60b210c9 (patch) | |
tree | b4d74d952847ff96f26c8c227bcaed17fef7ae80 | |
parent | 41614640be779ce133989bf733ba12e1efb5b040 (diff) | |
download | slp-pkgmgr-08331ae017c52a1d1ceef5f34f38a90b60b210c9.tar.gz slp-pkgmgr-08331ae017c52a1d1ceef5f34f38a90b60b210c9.tar.bz2 slp-pkgmgr-08331ae017c52a1d1ceef5f34f38a90b60b210c9.zip |
Fix bugs in loading plugin set
Fixes in the LoadPluginSet() function:
- the naming scheme for backend libraries is "libTYPE.so", where TYPE
is the backend type (e.g. for tpk it should load libtpk.so)
- elements of the global plugin_set_list array should be allocated
every time a new backend library is loaded as this behaviour is
expected by the backend api: pkg_plugin_on_load() function expects
its input parameter to be an already allocated memory area, otherwise
it returns -1 and the LoadPluginSet() reports a failure:
extern "C" int pkg_plugin_on_load(pkg_plugin_set* set) {
if (set == nullptr)
return -1;
set->plugin_on_unload = PluginOnUnload;
...
}
Change-Id: I603030871a28f050f1d87ce572c102c3d0b5dc90
-rw-r--r-- | client/src/internal.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/client/src/internal.cc b/client/src/internal.cc index a02ec3a..9fb08a9 100644 --- a/client/src/internal.cc +++ b/client/src/internal.cc @@ -74,7 +74,7 @@ pkg_plugin_set* LoadPluginSet(const std::string& type) { } } - std::string lib_path = kPkgLibPath + type + ".so"; + std::string lib_path = kPkgLibPath + std::string("lib") + type + ".so"; void* handle = dlopen(lib_path.c_str(), RTLD_LAZY); if (!handle) { _E("failed to load library %s", lib_path.c_str()); @@ -90,6 +90,13 @@ pkg_plugin_set* LoadPluginSet(const std::string& type) { return nullptr; } + plugin_set_list[i] = reinterpret_cast<pkg_plugin_set *>(calloc(1, sizeof(pkg_plugin_set))); + if (plugin_set_list[i] == NULL) { + _E("malloc of the plugin_set_list element is failed"); + dlclose(handle); + return nullptr; + } + if (on_load(plugin_set_list[i]) != 0) { _E("pkg_plugin_on_load failed"); free(plugin_set_list[i]); |