mirror of
https://gitee.com/openharmony/startup_appspawn
synced 2024-10-07 08:13:30 +00:00
fx bug for asan
Signed-off-by: zhongning5 <zhongning5@huawei.com>
This commit is contained in:
parent
686fe467c3
commit
ea342b99a6
@ -29,6 +29,11 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define HOOK_STOP_WHEN_ERROR 0x2
|
#define HOOK_STOP_WHEN_ERROR 0x2
|
||||||
|
#if defined(__aarch64__) || defined(__x86_64__)
|
||||||
|
#define ASAN_MODULE_PATH "/system/lib64/appspawn/libappspawn_asan"
|
||||||
|
#else
|
||||||
|
#define ASAN_MODULE_PATH "/system/lib/appspawn/libappspawn_asan"
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
MODULE_DEFAULT,
|
MODULE_DEFAULT,
|
||||||
|
@ -374,16 +374,12 @@ static int InitForkContext(AppSpawningCtx *property)
|
|||||||
if (option > 0) {
|
if (option > 0) {
|
||||||
(void)fcntl(property->forkCtx.fd[0], F_SETFD, option | O_NONBLOCK);
|
(void)fcntl(property->forkCtx.fd[0], F_SETFD, option | O_NONBLOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (property->client.flags & APP_COLD_START) { // for cold run, use shared memory to exchange message
|
|
||||||
APPSPAWN_LOGV("Write msg to child %{public}s", GetProcessName(property));
|
|
||||||
return WriteMsgToChild(property);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int AddChildWatcher(AppSpawningCtx *property)
|
static int AddChildWatcher(AppSpawningCtx *property)
|
||||||
{
|
{
|
||||||
|
uint32_t timeout = WAIT_CHILD_RESPONSE_TIMEOUT;
|
||||||
LE_WatchInfo watchInfo = {};
|
LE_WatchInfo watchInfo = {};
|
||||||
watchInfo.fd = property->forkCtx.fd[0];
|
watchInfo.fd = property->forkCtx.fd[0];
|
||||||
watchInfo.flags = WATCHER_ONCE;
|
watchInfo.flags = WATCHER_ONCE;
|
||||||
@ -394,7 +390,7 @@ static int AddChildWatcher(AppSpawningCtx *property)
|
|||||||
return APPSPAWN_SYSTEM_ERROR, "Failed to watch child %{public}d", property->pid);
|
return APPSPAWN_SYSTEM_ERROR, "Failed to watch child %{public}d", property->pid);
|
||||||
status = LE_CreateTimer(LE_GetDefaultLoop(), &property->forkCtx.timer, WaitChildTimeout, property);
|
status = LE_CreateTimer(LE_GetDefaultLoop(), &property->forkCtx.timer, WaitChildTimeout, property);
|
||||||
if (status == LE_SUCCESS) {
|
if (status == LE_SUCCESS) {
|
||||||
status = LE_StartTimer(LE_GetDefaultLoop(), property->forkCtx.timer, WAIT_CHILD_RESPONSE_TIMEOUT, 0);
|
status = LE_StartTimer(LE_GetDefaultLoop(), property->forkCtx.timer, timeout * 1000, 0); // 1000 1s
|
||||||
}
|
}
|
||||||
if (status != LE_SUCCESS) {
|
if (status != LE_SUCCESS) {
|
||||||
if (property->forkCtx.timer != NULL) {
|
if (property->forkCtx.timer != NULL) {
|
||||||
@ -576,6 +572,11 @@ static int AppSpawnColdStartApp(struct AppSpawnContent *content, AppSpawnClient
|
|||||||
char *path = property->forkCtx.coldRunPath != NULL ? property->forkCtx.coldRunPath : "/system/bin/appspawn";
|
char *path = property->forkCtx.coldRunPath != NULL ? property->forkCtx.coldRunPath : "/system/bin/appspawn";
|
||||||
APPSPAWN_LOGI("ColdStartApp::processName: %{public}s path: %{public}s", GetProcessName(property), path);
|
APPSPAWN_LOGI("ColdStartApp::processName: %{public}s path: %{public}s", GetProcessName(property), path);
|
||||||
|
|
||||||
|
// for cold run, use shared memory to exchange message
|
||||||
|
APPSPAWN_LOGV("Write msg to child %{public}s", GetProcessName(property));
|
||||||
|
int ret = WriteMsgToChild(property);
|
||||||
|
APPSPAWN_CHECK(ret == 0, return APPSPAWN_SYSTEM_ERROR, "Failed to write msg to child");
|
||||||
|
|
||||||
char buffer[4][32] = {0}; // 4 32 buffer for fd
|
char buffer[4][32] = {0}; // 4 32 buffer for fd
|
||||||
char *mode = IsNWebSpawnMode((AppSpawnMgr *)content) ? "nweb_cold" : "app_cold";
|
char *mode = IsNWebSpawnMode((AppSpawnMgr *)content) ? "nweb_cold" : "app_cold";
|
||||||
int len = sprintf_s(buffer[0], sizeof(buffer[0]), " %d ", property->forkCtx.fd[1]);
|
int len = sprintf_s(buffer[0], sizeof(buffer[0]), " %d ", property->forkCtx.fd[1]);
|
||||||
@ -593,7 +594,7 @@ static int AppSpawnColdStartApp(struct AppSpawnContent *content, AppSpawnClient
|
|||||||
"-param", GetProcessName(property), buffer[3], NULL
|
"-param", GetProcessName(property), buffer[3], NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
int ret = execv(path, (char **)formatCmds);
|
ret = execv(path, (char **)formatCmds);
|
||||||
if (ret != 0) {
|
if (ret != 0) {
|
||||||
APPSPAWN_LOGE("Failed to execv, errno: %{public}d", errno);
|
APPSPAWN_LOGE("Failed to execv, errno: %{public}d", errno);
|
||||||
}
|
}
|
||||||
@ -762,7 +763,7 @@ AppSpawnContent *StartSpawnService(const AppSpawnStartArg *startArg, uint32_t ar
|
|||||||
|
|
||||||
// load module appspawn/common
|
// load module appspawn/common
|
||||||
AppSpawnLoadAutoRunModules(MODULE_COMMON);
|
AppSpawnLoadAutoRunModules(MODULE_COMMON);
|
||||||
AppSpawnModuleMgrInstall("libappspawn_asan");
|
AppSpawnModuleMgrInstall(ASAN_MODULE_PATH);
|
||||||
|
|
||||||
APPSPAWN_CHECK(LE_GetDefaultLoop() != NULL, return NULL, "Invalid default loop");
|
APPSPAWN_CHECK(LE_GetDefaultLoop() != NULL, return NULL, "Invalid default loop");
|
||||||
AppSpawnContent *content = AppSpawnCreateContent(arg->socketName, argv[0], argvSize, arg->mode);
|
AppSpawnContent *content = AppSpawnCreateContent(arg->socketName, argv[0], argvSize, arg->mode);
|
||||||
|
@ -33,7 +33,7 @@ extern "C" {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MAX_WAIT_MSG_COMPLETE (5 * 1000) // 5s
|
#define MAX_WAIT_MSG_COMPLETE (5 * 1000) // 5s
|
||||||
#define WAIT_CHILD_RESPONSE_TIMEOUT 3000 //3s
|
#define WAIT_CHILD_RESPONSE_TIMEOUT 3 //3s
|
||||||
|
|
||||||
typedef struct TagAppSpawnMsgNode AppSpawnMsgNode;
|
typedef struct TagAppSpawnMsgNode AppSpawnMsgNode;
|
||||||
typedef struct TagAppSpawnMsgReceiverCtx {
|
typedef struct TagAppSpawnMsgReceiverCtx {
|
||||||
|
@ -105,7 +105,7 @@ void SetDumpToStream(FILE *stream);
|
|||||||
typedef int (*SplitStringHandle)(const char *str, void *context);
|
typedef int (*SplitStringHandle)(const char *str, void *context);
|
||||||
int32_t StringSplit(const char *str, const char *separator, void *context, SplitStringHandle handle);
|
int32_t StringSplit(const char *str, const char *separator, void *context, SplitStringHandle handle);
|
||||||
char *GetLastStr(const char *str, const char *dst);
|
char *GetLastStr(const char *str, const char *dst);
|
||||||
|
uint32_t GetSpawnTimeout(uint32_t def);
|
||||||
void DumpCurrentDir(char *buffer, uint32_t bufferLen, const char *dirPath);
|
void DumpCurrentDir(char *buffer, uint32_t bufferLen, const char *dirPath);
|
||||||
|
|
||||||
#ifndef APP_FILE_NAME
|
#ifndef APP_FILE_NAME
|
||||||
|
@ -308,3 +308,16 @@ void AppSpawnDump(const char *fmt, ...)
|
|||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
# pragma warning(pop)
|
# pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
uint32_t GetSpawnTimeout(uint32_t def)
|
||||||
|
{
|
||||||
|
uint32_t value = def;
|
||||||
|
char data[32] = {}; // 32 length
|
||||||
|
int ret = GetParameter("persist.appspawn.reqMgr.timeout", "0", data, sizeof(data));
|
||||||
|
if (ret > 0 && strcmp(data, "0") != 0) {
|
||||||
|
errno = 0;
|
||||||
|
value = atoi(data);
|
||||||
|
return (errno != 0) ? def : ((value < def) ? def : value);
|
||||||
|
}
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user