提交 9f5f6c9c 编写于 作者: M Mupceet

fix bug init

Signed-off-by: NMupceet <laiguizhong@huawei.com>
上级 54859a3e
...@@ -40,11 +40,7 @@ ohos_shared_library("deviceinfoservice") { ...@@ -40,11 +40,7 @@ ohos_shared_library("deviceinfoservice") {
] ]
deps = [ deps = [
"//base/startup/init_lite/services/log:agent_log", "//base/startup/init_lite/interfaces/innerkits:libbegetutil",
"//base/startup/init_lite/services/loopevent:loopevent",
"//base/startup/init_lite/services/param:param_client",
"//base/startup/init_lite/services/utils:libinit_tools",
"//base/startup/init_lite/services/utils:libinit_utils",
"//third_party/bounds_checking_function:libsec_shared", "//third_party/bounds_checking_function:libsec_shared",
"//third_party/openssl:libcrypto_shared", "//third_party/openssl:libcrypto_shared",
] ]
......
...@@ -226,8 +226,10 @@ if (defined(ohos_lite)) { ...@@ -226,8 +226,10 @@ if (defined(ohos_lite)) {
] ]
deps = [ deps = [
":libbegetutil",
"//base/startup/init_lite/services/utils:libinit_utils", "//base/startup/init_lite/services/utils:libinit_utils",
"//third_party/bounds_checking_function:libsec_shared", "//third_party/bounds_checking_function:libsec_shared",
"//third_party/openssl:libcrypto_shared",
] ]
if (enable_ohos_startup_init_feature_watcher) { if (enable_ohos_startup_init_feature_watcher) {
...@@ -241,12 +243,6 @@ if (defined(ohos_lite)) { ...@@ -241,12 +243,6 @@ if (defined(ohos_lite)) {
"//base/startup/init_lite/services/param/watcher/include", "//base/startup/init_lite/services/param/watcher/include",
"//base/startup/init_lite/services/log", "//base/startup/init_lite/services/log",
] ]
deps += [
"//base/startup/init_lite/services/param:param_client",
"//base/startup/init_lite/services/utils:libinit_tools",
"//base/startup/init_lite/services/utils:libinit_utils",
"//third_party/openssl:libcrypto_shared",
]
} else { } else {
defines += [ "NO_PARAM_WATCHER" ] defines += [ "NO_PARAM_WATCHER" ]
} }
...@@ -261,13 +257,6 @@ if (defined(ohos_lite)) { ...@@ -261,13 +257,6 @@ if (defined(ohos_lite)) {
sources += [ sources += [
"//base/startup/init_lite/interfaces/innerkits/syspara/param_comm.c", "//base/startup/init_lite/interfaces/innerkits/syspara/param_comm.c",
] ]
deps += [
"//base/startup/init_lite/services/loopevent:loopevent",
"//base/startup/init_lite/services/param:param_client",
"//base/startup/init_lite/services/utils:libinit_tools",
"//base/startup/init_lite/services/utils:libinit_utils",
"//third_party/openssl:libcrypto_shared",
]
} }
external_deps = [ external_deps = [
......
...@@ -74,7 +74,7 @@ int main(int argc, char *argv[]) ...@@ -74,7 +74,7 @@ int main(int argc, char *argv[])
printf("Failed to get shell handle \n"); printf("Failed to get shell handle \n");
return 0; return 0;
} }
SetInitLogLevel(0);
BShellParamCmdRegister(handle, 0); BShellParamCmdRegister(handle, 0);
#ifdef INIT_TEST #ifdef INIT_TEST
BShellCmdRegister(handle, 0); BShellCmdRegister(handle, 0);
......
...@@ -73,7 +73,6 @@ int main(int argc, char *args[]) ...@@ -73,7 +73,6 @@ int main(int argc, char *args[])
tio.c_cc[VMIN] = 1; tio.c_cc[VMIN] = 1;
tcsetattr(0, TCSAFLUSH, &tio); tcsetattr(0, TCSAFLUSH, &tio);
SetInitLogLevel(0);
BSH_LOGV("BShellEnvStart %d", argc); BSH_LOGV("BShellEnvStart %d", argc);
do { do {
BShellHandle handle = GetShellHandle(); BShellHandle handle = GetShellHandle();
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
#include "hilog_base/log_base.h" #include "hilog_base/log_base.h"
#endif #endif
#define DEF_LOG_SIZE 128
#define MAX_LOG_SIZE 1024 #define MAX_LOG_SIZE 1024
#define BASE_YEAR 1900 #define BASE_YEAR 1900
...@@ -105,9 +106,13 @@ void InitLog(InitLogLevel logLevel, unsigned int domain, const char *tag, const ...@@ -105,9 +106,13 @@ void InitLog(InitLogLevel logLevel, unsigned int domain, const char *tag, const
} }
va_list vargs; va_list vargs;
va_start(vargs, fmt); va_start(vargs, fmt);
char tmpFmt[MAX_LOG_SIZE] = {0}; char tmpFmt[DEF_LOG_SIZE] = {0};
if (vsnprintf_s(tmpFmt, MAX_LOG_SIZE, MAX_LOG_SIZE - 1, fmt, vargs) == -1) { if (vsnprintf_s(tmpFmt, sizeof(tmpFmt), sizeof(tmpFmt) - 1, fmt, vargs) == -1) {
va_end(vargs); va_end(vargs);
#ifdef OHOS_LITE
static LogLevel LOG_LEVEL[] = { LOG_DEBUG, LOG_INFO, LOG_WARN, LOG_ERROR, LOG_FATAL };
(void)HiLogPrint(INIT_LOG_INIT, LOG_LEVEL[logLevel], domain, tag, "%{public}s", fmt);
#endif
return; return;
} }
va_end(vargs); va_end(vargs);
......
...@@ -92,7 +92,6 @@ LE_STATUS ProcessEvent(const EventLoop *loop, int fd, uint32_t oper) ...@@ -92,7 +92,6 @@ LE_STATUS ProcessEvent(const EventLoop *loop, int fd, uint32_t oper)
} }
task->handleEvent((LoopHandle)loop, (TaskHandle)task, oper); task->handleEvent((LoopHandle)loop, (TaskHandle)task, oper);
} else { } else {
LE_LOGE("ProcessEvent can not find task for %d", fd);
loop->delEvent(loop, fd, oper); loop->delEvent(loop, fd, oper);
} }
return LE_SUCCESS; return LE_SUCCESS;
......
...@@ -44,13 +44,13 @@ static int InitParamClient(void) ...@@ -44,13 +44,13 @@ static int InitParamClient(void)
if (PARAM_TEST_FLAG(g_clientSpace.flags, WORKSPACE_FLAGS_INIT)) { if (PARAM_TEST_FLAG(g_clientSpace.flags, WORKSPACE_FLAGS_INIT)) {
return 0; return 0;
} }
PARAM_LOGV("InitParamClient"); PARAM_LOGI("InitParamClient %p", &g_clientSpace);
pthread_mutex_init(&g_clientSpace.mutex, NULL); pthread_mutex_init(&g_clientSpace.mutex, NULL);
g_clientSpace.clientFd = INVALID_SOCKET; g_clientSpace.clientFd = INVALID_SOCKET;
int ret = InitParamWorkSpace(1); int ret = InitParamWorkSpace(1);
PARAM_CHECK(ret == 0, return -1, "Failed to init param workspace"); PARAM_CHECK(ret == 0, return -1, "Failed to init param workspace");
PARAM_SET_FLAG(g_clientSpace.flags, WORKSPACE_FLAGS_INIT); PARAM_SET_FLAG(g_clientSpace.flags, WORKSPACE_FLAGS_INIT);
PARAM_LOGI("InitParamClient finish"); PARAM_LOGI("InitParamClient %p finish", &g_clientSpace);
return 0; return 0;
} }
...@@ -64,6 +64,7 @@ void ClientInit(void) ...@@ -64,6 +64,7 @@ void ClientInit(void)
void ClientDeinit(void) void ClientDeinit(void)
{ {
PARAM_LOGI("ClientDeinit %p", &g_clientSpace);
#ifndef STARTUP_INIT_TEST #ifndef STARTUP_INIT_TEST
if (PARAM_TEST_FLAG(g_clientSpace.flags, WORKSPACE_FLAGS_INIT)) { if (PARAM_TEST_FLAG(g_clientSpace.flags, WORKSPACE_FLAGS_INIT)) {
CloseParamWorkSpace(); CloseParamWorkSpace();
...@@ -74,6 +75,7 @@ void ClientDeinit(void) ...@@ -74,6 +75,7 @@ void ClientDeinit(void)
} }
PARAM_SET_FLAG(g_clientSpace.flags, 0); PARAM_SET_FLAG(g_clientSpace.flags, 0);
pthread_mutex_destroy(&g_clientSpace.mutex); pthread_mutex_destroy(&g_clientSpace.mutex);
PARAM_LOGI("ClientDeinit %p finish", &g_clientSpace);
} }
static int ProcessRecvMsg(const ParamMessage *recvMsg) static int ProcessRecvMsg(const ParamMessage *recvMsg)
...@@ -177,7 +179,6 @@ int SystemSetParameter(const char *name, const char *value) ...@@ -177,7 +179,6 @@ int SystemSetParameter(const char *name, const char *value)
request->msgSize = offset + sizeof(ParamMessage); request->msgSize = offset + sizeof(ParamMessage);
request->id.msgId = atomic_fetch_add(&g_requestId, 1); request->id.msgId = atomic_fetch_add(&g_requestId, 1);
PARAM_LOGV("SystemSetParameter name %s", name);
int fd = INVALID_SOCKET; int fd = INVALID_SOCKET;
pthread_mutex_lock(&g_clientSpace.mutex); pthread_mutex_lock(&g_clientSpace.mutex);
if (g_clientSpace.clientFd == INVALID_SOCKET) { if (g_clientSpace.clientFd == INVALID_SOCKET) {
...@@ -188,6 +189,7 @@ int SystemSetParameter(const char *name, const char *value) ...@@ -188,6 +189,7 @@ int SystemSetParameter(const char *name, const char *value)
PARAM_CHECK(fd > 0, return -1, "Failed to connect server for set %s", name); PARAM_CHECK(fd > 0, return -1, "Failed to connect server for set %s", name);
ret = StartRequest(fd, request, DEFAULT_PARAM_SET_TIMEOUT); ret = StartRequest(fd, request, DEFAULT_PARAM_SET_TIMEOUT);
free(request); free(request);
PARAM_LOGI("SystemSetParameter name %s %d", name, ret);
return ret; return ret;
} }
......
...@@ -117,6 +117,7 @@ PARAM_STATIC int RegisterSecurityOps(int onlyRead) ...@@ -117,6 +117,7 @@ PARAM_STATIC int RegisterSecurityOps(int onlyRead)
int InitParamWorkSpace(int onlyRead) int InitParamWorkSpace(int onlyRead)
{ {
PARAM_LOGI("InitParamWorkSpace %p", &g_paramWorkSpace);
if (PARAM_TEST_FLAG(g_paramWorkSpace.flags, WORKSPACE_FLAGS_INIT)) { if (PARAM_TEST_FLAG(g_paramWorkSpace.flags, WORKSPACE_FLAGS_INIT)) {
return 0; return 0;
} }
...@@ -695,7 +696,6 @@ WorkSpace *GetWorkSpace(const char *name) ...@@ -695,7 +696,6 @@ WorkSpace *GetWorkSpace(const char *name)
space = HASHMAP_ENTRY(node, WorkSpace, hashNode); space = HASHMAP_ENTRY(node, WorkSpace, hashNode);
} }
WORKSPACE_RW_UNLOCK(g_paramWorkSpace); WORKSPACE_RW_UNLOCK(g_paramWorkSpace);
PARAM_LOGV("GetWorkSpace %s space-name %s, space %p", name, tmpName, space);
return (space != NULL && space->area != NULL) ? space : NULL; return (space != NULL && space->area != NULL) ? space : NULL;
} }
......
...@@ -112,12 +112,14 @@ int InitWorkSpace(WorkSpace *workSpace, int onlyRead, uint32_t spaceSize) ...@@ -112,12 +112,14 @@ int InitWorkSpace(WorkSpace *workSpace, int onlyRead, uint32_t spaceSize)
PARAM_CHECK(ret == 0, return ret, "Failed to init workspace %s", workSpace->fileName); PARAM_CHECK(ret == 0, return ret, "Failed to init workspace %s", workSpace->fileName);
PARAMSPACE_AREA_INIT_LOCK(workSpace); PARAMSPACE_AREA_INIT_LOCK(workSpace);
PARAM_SET_FLAG(workSpace->flags, WORKSPACE_FLAGS_INIT); PARAM_SET_FLAG(workSpace->flags, WORKSPACE_FLAGS_INIT);
PARAM_LOGI("InitWorkSpace %s", workSpace->fileName);
return ret; return ret;
} }
void CloseWorkSpace(WorkSpace *workSpace) void CloseWorkSpace(WorkSpace *workSpace)
{ {
PARAM_CHECK(workSpace != NULL, return, "The workspace is null"); PARAM_CHECK(workSpace != NULL, return, "The workspace is null");
PARAM_LOGI("CloseWorkSpace %s", workSpace->fileName);
if (!PARAM_TEST_FLAG(workSpace->flags, WORKSPACE_FLAGS_INIT)) { if (!PARAM_TEST_FLAG(workSpace->flags, WORKSPACE_FLAGS_INIT)) {
free(workSpace); free(workSpace);
return; return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册