Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
a7646b8d
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看板
未验证
提交
a7646b8d
编写于
1月 24, 2022
作者:
O
openharmony_ci
提交者:
Gitee
1月 24, 2022
浏览文件
操作
浏览文件
下载
差异文件
!262 【轻量级 PR】:取消sigisemptyset函数的使用 Signed-off-by: xionglei <xionglei6@huawei.com>
Merge pull request !262 from 熊磊/N/A
上级
986583f9
9a9c8aa2
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
9 addition
and
6 deletion
+9
-6
services/loopevent/signal/le_signal.c
services/loopevent/signal/le_signal.c
+8
-6
services/loopevent/signal/le_signal.h
services/loopevent/signal/le_signal.h
+1
-0
未找到文件。
services/loopevent/signal/le_signal.c
浏览文件 @
a7646b8d
...
...
@@ -52,7 +52,7 @@ LE_STATUS LE_CreateSignalTask(const LoopHandle loopHandle, SignalHandle *signalH
{
LE_CHECK
(
loopHandle
!=
NULL
&&
signalHandle
!=
NULL
,
return
LE_INVALID_PARAM
,
"Invalid parameters"
);
LE_CHECK
(
processSignal
!=
NULL
,
return
LE_FAILURE
,
"Invalid parameters processSignal"
);
sigset_t
mask
=
{}
;
sigset_t
mask
;
sigemptyset
(
&
mask
);
int
sfd
=
signalfd
(
-
1
,
&
mask
,
SFD_NONBLOCK
);
LE_CHECK
(
sfd
>
0
,
return
-
1
,
"Failed to create signal fd"
);
...
...
@@ -61,6 +61,7 @@ LE_STATUS LE_CreateSignalTask(const LoopHandle loopHandle, SignalHandle *signalH
LE_CHECK
(
task
!=
NULL
,
return
LE_NO_MEMORY
,
"Failed to create task"
);
task
->
base
.
handleEvent
=
HandleSignalEvent_
;
task
->
base
.
innerClose
=
HandleSignalTaskClose_
;
task
->
sigNumber
=
0
;
sigemptyset
(
&
task
->
mask
);
task
->
processSignal
=
processSignal
;
*
signalHandle
=
(
SignalHandle
)
task
;
...
...
@@ -72,8 +73,7 @@ LE_STATUS LE_AddSignal(const LoopHandle loopHandle, const SignalHandle signalHan
LE_CHECK
(
loopHandle
!=
NULL
&&
signalHandle
!=
NULL
,
return
LE_INVALID_PARAM
,
"Invalid parameters"
);
EventLoop
*
loop
=
(
EventLoop
*
)
loopHandle
;
SignalTask
*
task
=
(
SignalTask
*
)
signalHandle
;
int
empty
=
sigisemptyset
(
&
task
->
mask
);
LE_LOGI
(
"LE_AddSignal %d %d"
,
signal
,
empty
);
LE_LOGI
(
"LE_AddSignal %d %d"
,
signal
,
task
->
sigNumber
);
if
(
sigismember
(
&
task
->
mask
,
signal
))
{
return
LE_SUCCESS
;
}
...
...
@@ -81,11 +81,12 @@ LE_STATUS LE_AddSignal(const LoopHandle loopHandle, const SignalHandle signalHan
sigprocmask
(
SIG_BLOCK
,
&
task
->
mask
,
NULL
);
int
sfd
=
signalfd
(
GetSocketFd
(
signalHandle
),
&
task
->
mask
,
SFD_NONBLOCK
);
LE_CHECK
(
sfd
>
0
,
return
-
1
,
"Failed to create signal fd"
);
if
(
empty
)
{
if
(
task
->
sigNumber
==
0
)
{
loop
->
addEvent
(
loop
,
(
const
BaseTask
*
)
task
,
Event_Read
);
}
else
{
loop
->
modEvent
(
loop
,
(
const
BaseTask
*
)
task
,
Event_Read
);
}
task
->
sigNumber
++
;
return
LE_SUCCESS
;
}
...
...
@@ -94,14 +95,15 @@ LE_STATUS LE_RemoveSignal(const LoopHandle loopHandle, const SignalHandle signal
LE_CHECK
(
loopHandle
!=
NULL
&&
signalHandle
!=
NULL
,
return
LE_INVALID_PARAM
,
"Invalid parameters"
);
EventLoop
*
loop
=
(
EventLoop
*
)
loopHandle
;
SignalTask
*
task
=
(
SignalTask
*
)
signalHandle
;
LE_LOGI
(
"LE_RemoveSignal %d
"
,
signal
);
LE_LOGI
(
"LE_RemoveSignal %d
%d"
,
signal
,
task
->
sigNumber
);
if
(
!
sigismember
(
&
task
->
mask
,
signal
))
{
return
LE_SUCCESS
;
}
sigdelset
(
&
task
->
mask
,
signal
);
task
->
sigNumber
--
;
int
sfd
=
signalfd
(
GetSocketFd
(
signalHandle
),
&
task
->
mask
,
SFD_NONBLOCK
);
LE_CHECK
(
sfd
>
0
,
return
-
1
,
"Failed to create signal fd"
);
if
(
sigisemptyset
(
&
task
->
mask
)
)
{
if
(
task
->
sigNumber
<=
0
)
{
loop
->
delEvent
(
loop
,
GetSocketFd
(
signalHandle
),
Event_Read
);
}
return
LE_SUCCESS
;
...
...
services/loopevent/signal/le_signal.h
浏览文件 @
a7646b8d
...
...
@@ -23,6 +23,7 @@
typedef
struct
{
BaseTask
base
;
sigset_t
mask
;
int
sigNumber
;
LE_ProcessSignal
processSignal
;
}
SignalTask
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录