修改L1 Linux启动失败

Signed-off-by: laiguizhong <laiguizhong@huawei.com>
This commit is contained in:
laiguizhong 2022-05-11 14:29:45 +08:00
parent 73df2c2966
commit 55700a6e97
4 changed files with 23 additions and 14 deletions

View File

@ -20,7 +20,6 @@ lite_component("appspawn_lite") {
# feature: appspawn
executable("appspawn") {
sources = [
"../adapter/appspawn_log.cpp",
"../common/appspawn_server.c",
"appspawn_message.c",
"appspawn_process.c",
@ -78,7 +77,7 @@ executable("appspawn") {
}
if (ohos_kernel_type == "linux") {
include_dirs += []
defines += [ "__LINUX__" ]
}
}

View File

@ -28,6 +28,7 @@
#include "ohos_init.h"
#include "samgr_lite.h"
#include "service.h"
#include "securec.h"
static const int INVALID_PID = -1;
static const int CLIENT_ID = 100;
@ -118,8 +119,11 @@ AppSpawnContent *AppSpawnCreateContent(const char *socketName, char *longProcNam
APPSPAWN_LOGI("AppSpawnCreateContent %s", socketName);
AppSpawnContentLite *appSpawnContent = (AppSpawnContentLite *)malloc(sizeof(AppSpawnContentLite));
APPSPAWN_CHECK(appSpawnContent != NULL, return NULL, "Failed to alloc memory for appspawn");
int ret = memset_s(appSpawnContent, sizeof(AppSpawnContentLite), 0, sizeof(AppSpawnContentLite));
APPSPAWN_CHECK(ret == 0, free(appSpawnContent);
return NULL, "Failed to memset conent");
appSpawnContent->content.longProcName = NULL;
appSpawnContent->content.longProcNameLen = NULL;
appSpawnContent->content.longProcNameLen = 0;
g_appSpawnContentLite = appSpawnContent;
return appSpawnContent;
}
@ -139,26 +143,25 @@ static int Invoke(IServerProxy *iProxy, int funcId, void *origin, IpcIo *req, Ip
IpcIoPushInt64(reply, INVALID_PID);
return EC_BADPTR;
}
AppSpawnClientLite *client = (AppSpawnClientLite *)malloc(sizeof(AppSpawnClientLite));
APPSPAWN_CHECK(client != NULL, return -1, "malloc AppSpawnClientLite Failed");
client->client.id = CLIENT_ID;
client->client.flags = 0;
if (GetMessageSt(&client->message, req) != EC_SUCCESS) {
APPSPAWN_LOGI("[appspawn] invoke.");
AppSpawnClientLite client = {};
client.client.id = CLIENT_ID;
client.client.flags = 0;
if (GetMessageSt(&client.message, req) != EC_SUCCESS) {
APPSPAWN_LOGE("[appspawn] invoke, parse failed! reply %d.", INVALID_PID);
IpcIoPushInt64(reply, INVALID_PID);
return EC_FAILURE;
}
APPSPAWN_LOGI("[appspawn] invoke, msg<%s,%s,%d,%d %d>", client->message.bundleName, client->message.identityID,
client->message.uID, client->message.gID, client->message.capsCnt);
APPSPAWN_LOGI("[appspawn] invoke, msg<%s,%s,%d,%d %d>", client.message.bundleName, client.message.identityID,
client.message.uID, client.message.gID, client.message.capsCnt);
pid_t newPid = 0;
int ret = AppSpawnProcessMsg(g_appSpawnContentLite, &client->client, &newPid);
int ret = AppSpawnProcessMsg(&g_appSpawnContentLite->content, &client.client, &newPid);
if (ret != 0) {
newPid = -1;
}
FreeMessageSt(&client->message);
FreeMessageSt(&client.message);
IpcIoPushInt64(reply, newPid);
#ifdef OHOS_DEBUG

View File

@ -38,6 +38,9 @@
"build": {
"sub_component": [
"//base/startup/appspawn_standard/lite:appspawn_lite"
],
"test": [
"//base/startup/appspawn_standard/test/unittest/app_spawn_lite_test:unittest"
]
}
}

View File

@ -67,7 +67,11 @@ int main(int argc, char * const argv[])
sleep(1);
APPSPAWN_LOGI("[appspawn] main, enter.");
AppSpawnContent *content = AppSpawnCreateContent("AppSpawn", NULL, 0, 0);
AppSpawnContent *content = AppSpawnCreateContent(APPSPAWN_SERVICE_NAME, NULL, 0, 0);
if (content == NULL) {
APPSPAWN_LOGE("Failed to create content for appspawn");
return -1;
}
SetContentFunction(content);
// 1. ipc module init
HOS_SystemInit();