mirror of
https://gitee.com/openharmony/startup_appspawn
synced 2025-02-17 02:29:23 +00:00
!29 Optimize libace.z.so load process
Merge pull request !29 from guozejun/master
This commit is contained in:
commit
fe486294e4
@ -143,6 +143,13 @@ private:
|
||||
*/
|
||||
bool CheckAppProperty(const ClientSocket::AppProperty *appProperty);
|
||||
|
||||
#ifdef ACEABILITY_LIBRARY_LOADER
|
||||
/**
|
||||
* Load libace.z.so library when boot the devices
|
||||
*/
|
||||
void LoadAceLib();
|
||||
#endif
|
||||
|
||||
private:
|
||||
const std::string deviceNull_ = "/dev/null";
|
||||
std::string socketName_ {};
|
||||
|
@ -28,6 +28,11 @@
|
||||
#include "main_thread.h"
|
||||
#include "securec.h"
|
||||
|
||||
#if defined(ABILITY_LIBRARY_LOADER) || defined(APPLICATION_LIBRARY_LOADER)
|
||||
#include <dirent.h>
|
||||
#include <dlfcn.h>
|
||||
#endif
|
||||
|
||||
#define GRAPHIC_PERMISSION_CHECK
|
||||
|
||||
namespace OHOS {
|
||||
@ -147,6 +152,22 @@ void AppSpawnServer::ConnectionPeer()
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ACEABILITY_LIBRARY_LOADER
|
||||
void AppSpawnServer::LoadAceLib()
|
||||
{
|
||||
std::string acelibdir("/system/lib/libace.z.so");
|
||||
void *AceAbilityLib = nullptr;
|
||||
HiLog::Info(LABEL, "MainThread::LoadAbilityLibrary. Start calling dlopen acelibdir.");
|
||||
AceAbilityLib = dlopen(acelibdir.c_str(), RTLD_NOW | RTLD_GLOBAL);
|
||||
if (AceAbilityLib == nullptr) {
|
||||
HiLog::Error(LABEL, "Fail to dlopen %{public}s, [%{public}s]", acelibdir.c_str(), dlerror());
|
||||
} else {
|
||||
HiLog::Info(LABEL, "Success to dlopen %{public}s", acelibdir.c_str());
|
||||
}
|
||||
HiLog::Info(LABEL, "MainThread::LoadAbilityLibrary. End calling dlopen.");
|
||||
}
|
||||
#endif
|
||||
|
||||
bool AppSpawnServer::ServerMain(char *longProcName, int64_t longProcNameLen)
|
||||
{
|
||||
if (socket_->RegisterServerSocket() != 0) {
|
||||
@ -154,7 +175,9 @@ bool AppSpawnServer::ServerMain(char *longProcName, int64_t longProcNameLen)
|
||||
return false;
|
||||
}
|
||||
std::thread(&AppSpawnServer::ConnectionPeer, this).detach();
|
||||
|
||||
#ifdef ACEABILITY_LIBRARY_LOADER
|
||||
LoadAceLib();
|
||||
#endif
|
||||
while (isRunning_) {
|
||||
std::unique_lock<std::mutex> lock(mut_);
|
||||
dataCond_.wait(lock, [this] { return !this->appQueue_.empty(); });
|
||||
|
Loading…
x
Reference in New Issue
Block a user