Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
d6793472
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
1 年多 前同步成功
通知
3
Star
37
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Startup Init Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d6793472
编写于
12月 29, 2021
作者:
X
xionglei6
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
init: fix service control extra bugs
Signed-off-by:
N
xionglei6
<
xionglei6@huawei.com
>
上级
c4bb8408
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
16 addition
and
24 deletion
+16
-24
services/init/include/init_service.h
services/init/include/init_service.h
+1
-1
services/init/init_service_manager.c
services/init/init_service_manager.c
+12
-3
services/init/lite/init_service.c
services/init/lite/init_service.c
+1
-1
services/init/standard/init_service.c
services/init/standard/init_service.c
+2
-19
未找到文件。
services/init/include/init_service.h
浏览文件 @
d6793472
...
...
@@ -101,7 +101,7 @@ void NotifyServiceChange(const char *serviceName, const char *change);
int
IsForbidden
(
const
char
*
fieldStr
);
int
SetImportantValue
(
Service
*
curServ
,
const
char
*
attrName
,
int
value
,
int
flag
);
int
GetServiceCaps
(
const
cJSON
*
curArrItem
,
Service
*
curServ
);
int
ServiceExec
(
Service
*
service
);
int
ServiceExec
(
const
Service
*
service
);
#ifdef __cplusplus
#if __cplusplus
...
...
services/init/init_service_manager.c
浏览文件 @
d6793472
...
...
@@ -680,6 +680,9 @@ void StartServiceByName(const char *servName, bool checkDynamic)
if
(
ServiceStart
(
service
)
!=
SERVICE_SUCCESS
)
{
INIT_LOGE
(
"Service %s start failed!"
,
servName
);
}
FreeStringVector
(
service
->
extraArgs
.
argv
,
service
->
extraArgs
.
count
);
service
->
extraArgs
.
argv
=
NULL
;
service
->
extraArgs
.
count
=
0
;
return
;
}
...
...
@@ -729,13 +732,19 @@ static int SetServiceExtraArgs(Service *service, const char *fullServName)
char
**
extArgv
=
SplitStringExt
(
tmpServName
,
"|"
,
&
returnCount
,
MAX_PATH_ARGS_CNT
);
free
(
tmpServName
);
INIT_ERROR_CHECK
(
extArgv
!=
NULL
&&
returnCount
>
0
,
return
-
1
,
"Split servName: %s failed"
,
fullServName
);
service
->
extraArgs
.
count
=
returnCount
-
1
;
service
->
extraArgs
.
count
=
service
->
pathArgs
.
count
+
returnCount
-
1
;
service
->
extraArgs
.
argv
=
(
char
**
)
calloc
(
service
->
extraArgs
.
count
,
sizeof
(
char
*
));
INIT_ERROR_CHECK
(
service
->
extraArgs
.
argv
!=
NULL
,
FreeStringVector
(
extArgv
,
returnCount
);
return
-
1
,
"Failed calloc err=%d"
,
errno
);
for
(
int
i
=
0
;
i
<
service
->
extraArgs
.
count
;
i
++
)
{
service
->
extraArgs
.
argv
[
i
]
=
strdup
(
extArgv
[
i
+
1
]);
int
argc
;
for
(
argc
=
0
;
argc
<
(
service
->
pathArgs
.
count
-
1
);
argc
++
)
{
service
->
extraArgs
.
argv
[
argc
]
=
strdup
(
service
->
pathArgs
.
argv
[
argc
]);
}
int
extArgc
;
for
(
extArgc
=
0
;
extArgc
<
(
returnCount
-
1
);
extArgc
++
)
{
service
->
extraArgs
.
argv
[
extArgc
+
argc
]
=
strdup
(
extArgv
[
extArgc
+
1
]);
}
service
->
extraArgs
.
argv
[
service
->
extraArgs
.
count
]
=
NULL
;
FreeStringVector
(
extArgv
,
returnCount
);
return
0
;
}
...
...
services/init/lite/init_service.c
浏览文件 @
d6793472
...
...
@@ -62,7 +62,7 @@ int SetImportantValue(Service *service, const char *attrName, int value, int fla
return
SERVICE_SUCCESS
;
}
int
ServiceExec
(
Service
*
service
)
int
ServiceExec
(
const
Service
*
service
)
{
INIT_ERROR_CHECK
(
service
!=
NULL
&&
service
->
pathArgs
.
count
>
0
,
return
SERVICE_FAILURE
,
"Exec service failed! null ptr."
);
...
...
services/init/standard/init_service.c
浏览文件 @
d6793472
...
...
@@ -57,7 +57,7 @@ int SetImportantValue(Service *service, const char *attrName, int value, int fla
return
SERVICE_SUCCESS
;
}
int
ServiceExec
(
Service
*
service
)
int
ServiceExec
(
const
Service
*
service
)
{
INIT_ERROR_CHECK
(
service
!=
NULL
&&
service
->
pathArgs
.
count
>
0
,
return
SERVICE_FAILURE
,
"Exec service failed! null ptr."
);
...
...
@@ -70,25 +70,8 @@ int ServiceExec(Service *service)
INIT_CHECK_ONLY_ELOG
(
unsetenv
(
"UV_THREADPOOL_SIZE"
)
==
0
,
"set UV_THREADPOOL_SIZE error : %d."
,
errno
);
// L2 Can not be reset env
if
(
service
->
extraArgs
.
argv
!=
NULL
&&
service
->
extraArgs
.
count
>
0
)
{
char
**
argv
=
(
char
**
)
calloc
(
service
->
pathArgs
.
count
+
service
->
extraArgs
.
count
,
sizeof
(
char
*
));
INIT_ERROR_CHECK
(
argv
!=
NULL
,
FreeStringVector
(
service
->
extraArgs
.
argv
,
service
->
extraArgs
.
count
);
return
SERVICE_FAILURE
,
"Failed calloc argv"
);
int
tArgc
=
service
->
pathArgs
.
count
+
service
->
extraArgs
.
count
;
int
argc
=
0
;
for
(
argc
=
0
;
argc
<
service
->
pathArgs
.
count
-
1
;
argc
++
)
{
argv
[
argc
]
=
strdup
(
service
->
pathArgs
.
argv
[
argc
]);
}
int
eArgc
=
0
;
for
(
eArgc
=
0
;
eArgc
<
service
->
extraArgs
.
count
;
eArgc
++
)
{
argv
[
argc
+
eArgc
]
=
strdup
(
service
->
extraArgs
.
argv
[
eArgc
]);
}
argv
[
tArgc
]
=
NULL
;
INIT_CHECK_ONLY_ELOG
(
execv
(
argv
[
0
],
argv
)
==
0
,
INIT_CHECK_ONLY_ELOG
(
execv
(
service
->
extraArgs
.
argv
[
0
],
service
->
extraArgs
.
argv
)
==
0
,
"service %s execve failed! err %d."
,
service
->
name
,
errno
);
FreeStringVector
(
argv
,
tArgc
);
FreeStringVector
(
service
->
extraArgs
.
argv
,
service
->
extraArgs
.
count
);
service
->
extraArgs
.
argv
=
NULL
;
service
->
extraArgs
.
count
=
0
;
}
else
{
INIT_CHECK_ONLY_ELOG
(
execv
(
service
->
pathArgs
.
argv
[
0
],
service
->
pathArgs
.
argv
)
==
0
,
"service %s execve failed! err %d."
,
service
->
name
,
errno
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录