Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Musl
提交
935f0ffb
T
Third Party Musl
项目概览
OpenHarmony
/
Third Party Musl
1 年多 前同步成功
通知
37
Star
125
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Musl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
935f0ffb
编写于
1月 17, 2023
作者:
D
dhy308
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix sigchain bug for thread key
Issue: I6AEEI Test: Build & Boot Devices Signed-off-by:
N
dhy308
<
tony.gan@huawei.com
>
上级
2c9eae1d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
97 addition
and
29 deletion
+97
-29
include/sigchain.h
include/sigchain.h
+15
-0
ndk_musl_include/sigchain.h
ndk_musl_include/sigchain.h
+15
-0
porting/linux/user/include/sigchain.h
porting/linux/user/include/sigchain.h
+15
-0
porting/linux/user/src/sigchain/sigchain.c
porting/linux/user/src/sigchain/sigchain.c
+51
-27
porting/linux/user/src/signal/sigaction.c
porting/linux/user/src/signal/sigaction.c
+1
-2
未找到文件。
include/sigchain.h
浏览文件 @
935f0ffb
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _SIGCHAIN_H
#define _SIGCHAIN_H
...
...
ndk_musl_include/sigchain.h
浏览文件 @
935f0ffb
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _SIGCHAIN_H
#define _SIGCHAIN_H
...
...
porting/linux/user/include/sigchain.h
浏览文件 @
935f0ffb
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef _SIGCHAIN_H
#define _SIGCHAIN_H
...
...
porting/linux/user/src/sigchain/sigchain.c
浏览文件 @
935f0ffb
/*
* Copyright (c) 2023 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <sigchain.h>
#include <locale.h>
#include <pthread.h>
#include <errno.h>
#include <stdio.h>
#include <threads.h>
extern
int
__libc_sigaction
(
int
sig
,
const
struct
sigaction
*
restrict
sa
,
struct
sigaction
*
restrict
old
);
...
...
@@ -10,7 +26,7 @@ extern int __libc_sigaction(int sig, const struct sigaction *restrict sa,
#define SIG_CHAIN_KEY_VALUE_1 1
#define SIGNAL_CHAIN_SPECIAL_ACTION_MAX 2
#if SIGCHAIN_DEBUG
#if
def
SIGCHAIN_DEBUG
#ifndef SIGCHAIN_PRINT_DEBUG
#define SIGCHAIN_PRINT_DEBUG(fmt, ...) printf("SIGCHAIN D " fmt "\n", ##__VA_ARGS__)
#endif
...
...
@@ -33,37 +49,44 @@ struct sc_signal_chain {
/* Signal chain set, from 0 to 63. */
static
struct
sc_signal_chain
sig_chains
[
_NSIG
-
1
];
/* static thread Keyword */
static
pthread_key_t
sigchain_key
;
static
pthread_key_t
g_sigchain_key
;
/* This is once flag! */
static
once_flag
g_flag
=
ONCE_FLAG_INIT
;
/**
* @brief Create the thread key
* @retval void
*/
void
do_once
(
void
)
{
int
rc
=
pthread_key_create
(
&
g_sigchain_key
,
NULL
);
if
(
rc
!=
0
)
{
SIGCHAIN_PRINT_ERROR
(
"%s failed to create sigchain pthread key"
,
__func__
,
rc
);
}
}
/**
* @brief Get the key of the signal thread.
* @retval int32_t, the value of the sigchain key.
*/
static
pthread_key_t
get_handling_signal_key
()
{
static
bool
isCreated
=
false
;
if
(
!
isCreated
)
{
/* Create a thread key. */
int
rc
=
pthread_key_create
(
&
sigchain_key
,
NULL
);
if
(
rc
!=
0
)
{
SIGCHAIN_PRINT_ERROR
(
"%s failed to create sigchain pthread key"
,
__func__
,
rc
);
}
else
{
isCreated
=
true
;
int32_t
value
=
0
;
pthread_setspecific
(
sigchain_key
,
&
value
);
}
}
return
sigchain_key
;
call_once
(
&
g_flag
,
do_once
);
return
g_sigchain_key
;
}
/**
* @brief Get the value of the sigchain key
* @retval
int32_t, the value of the sigchain key
.
* @retval
bool, true if set the value of the key,or false
.
*/
static
int32_t
get_handling_signal
()
{
int32_t
*
result
=
pthread_getspecific
(
get_handling_signal_key
());
return
*
result
;
static
bool
get_handling_signal
()
{
void
*
result
=
pthread_getspecific
(
get_handling_signal_key
());
if
(
result
==
NULL
)
{
return
false
;
}
else
{
return
true
;
}
}
/**
...
...
@@ -71,9 +94,10 @@ static int32_t get_handling_signal() {
* @param[in] value, the value of the sigchain key
* @retval void.
*/
static
void
set_handling_signal
(
int32_t
value
)
{
static
void
set_handling_signal
(
bool
value
)
{
pthread_setspecific
(
get_handling_signal_key
(),
&
value
);
(
void
*
)((
uintptr_t
)(
value
))
);
}
/**
...
...
@@ -98,7 +122,7 @@ static void signal_chain_handler(int signo, siginfo_t* siginfo, void* ucontext_r
{
SIGCHAIN_PRINT_DEBUG
(
"%s signo: %d"
,
__func__
,
signo
);
/* Try to call the special handlers first. */
if
(
get_handling_signal
()
==
0
){
if
(
!
get_handling_signal
()
){
int
len
=
SIGNAL_CHAIN_SPECIAL_ACTION_MAX
;
for
(
int
i
=
0
;
i
<
len
;
i
++
)
{
if
(
sig_chains
[
signo
-
1
].
sca_special_actions
[
i
].
sca_sigaction
==
NULL
)
{
...
...
@@ -111,9 +135,9 @@ static void signal_chain_handler(int signo, siginfo_t* siginfo, void* ucontext_r
pthread_sigmask
(
SIG_SETMASK
,
&
sig_chains
[
signo
-
1
].
sca_special_actions
[
i
].
sca_mask
,
&
previous_mask
);
int32_t
previous_value
=
get_handling_signal
();
bool
previous_value
=
get_handling_signal
();
if
(
!
noreturn
)
{
set_handling_signal
(
SIG_CHAIN_KEY_VALUE_1
);
set_handling_signal
(
true
);
}
if
(
sig_chains
[
signo
-
1
].
sca_special_actions
[
i
].
sca_sigaction
(
signo
,
...
...
@@ -328,7 +352,7 @@ bool intercept_sigaction(int signo, const struct sigaction *restrict sa,
void
intercept_sigprocmask
(
int
how
,
sigset_t
*
restrict
set
)
{
SIGCHAIN_PRINT_DEBUG
(
"%s how: %d"
,
__func__
,
how
);
if
(
get_handling_signal
()
!=
0
)
{
if
(
get_handling_signal
())
{
return
;
}
...
...
porting/linux/user/src/signal/sigaction.c
浏览文件 @
935f0ffb
#include <signal.h>
#include <errno.h>
#include <string.h>
#include <s
igchain
.h>
#include <s
tdbool
.h>
#include "syscall.h"
#include "pthread_impl.h"
#include "libc.h"
...
...
@@ -85,7 +85,6 @@ int __sigaction(int sig, const struct sigaction *restrict sa, struct sigaction *
errno
=
EINVAL
;
return
-
1
;
}
if
(
intercept_sigaction
(
sig
,
sa
,
old
))
{
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录