#include <parcel.hh>
#include <vconf.h>
+#include <mutex>
#include <string>
#include "parcelable_factory.hh"
bool PkgInfoClient::RequestHandlerDirectAccess(
const std::vector<uint8_t>& raw) {
+ static std::mutex lock;
static void* handle = nullptr;
- static void* (*dl_func)(int, const unsigned char*, int, const char *);
+ static void* (*dl_func)(int, const unsigned char*, int, const char*);
+ std::unique_lock<std::mutex> u(lock);
if (handle == nullptr) {
handle = dlopen(LIBPKGMGR_INFO, RTLD_GLOBAL | RTLD_LAZY);
if (!handle) {
return false;
}
dl_func = reinterpret_cast<void* (*)(
- int, const unsigned char*, int, const char *)>(
+ int, const unsigned char*, int, const char*)>(
dlsym(handle, DIRECT_ACCESS_FUNC));
if (dl_func == nullptr) {
LOG(ERROR) << "cannot find " << DIRECT_ACCESS_FUNC << " symbol in "
return false;
}
}
+ u.unlock();
result_parcel_.reset(
- reinterpret_cast<pkgmgr_common::parcel::AbstractParcelable *>(
+ reinterpret_cast<pkgmgr_common::parcel::AbstractParcelable*>(
dl_func(req_type_, &raw[0], raw.size(),
pkgmgr_common::SystemLocale::GetInst(false).Get().c_str())));