gazelle/0315-Stack-unset-stack_stop-while-stacks-exit-by-rpc-mess.patch
yinbin 2ad4d8b8db sync SIGNAL: block SIGSEGV during exit process
(cherry picked from commit 0997bc86367e1038eec8bbdc0ec0773b3a95c331)
2025-03-04 20:06:35 +08:00

75 lines
2.5 KiB
Diff

From 51e3c4f57dfcd6400df17bbebe18f544b90e134f Mon Sep 17 00:00:00 2001
From: yinbin <yinbin8@huawei.com>
Date: Tue, 14 Jan 2025 10:19:27 +0800
Subject: [PATCH] Stack: unset stack_stop, while stacks exit by rpc message.
---
src/lstack/api/lstack_unistd.c | 2 +-
src/lstack/core/lstack_protocol_stack.c | 3 ++-
src/lstack/core/lstack_thread_rpc.c | 1 -
src/lstack/include/lstack_protocol_stack.h | 2 +-
4 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/lstack/api/lstack_unistd.c b/src/lstack/api/lstack_unistd.c
index 0837a6b..d8b5d8e 100644
--- a/src/lstack/api/lstack_unistd.c
+++ b/src/lstack/api/lstack_unistd.c
@@ -71,7 +71,7 @@ static void lstack_sigaction_default_handler(int sig, siginfo_t *info, void *con
LSTACK_LOG(ERR, LSTACK, "lstack dumped, caught signal: %d\n", sig);
- stack_stop();
+ stack_wait();
if (sig_need_dump(sig)) {
/* dump stack info */
diff --git a/src/lstack/core/lstack_protocol_stack.c b/src/lstack/core/lstack_protocol_stack.c
index 1eebac4..fcc0ad7 100644
--- a/src/lstack/core/lstack_protocol_stack.c
+++ b/src/lstack/core/lstack_protocol_stack.c
@@ -795,7 +795,7 @@ void stack_exit(void)
}
}
-void stack_stop(void)
+void stack_wait(void)
{
struct protocol_stack *stack = get_protocol_stack();
if (stack != NULL) {
@@ -824,6 +824,7 @@ void stack_group_exit(void)
stack_exit();
}
+ /* Waiting all stacks' status transfer to WAIT, which means stacks are ready to exit. */
for (i = 0; i < stack_group->stack_num; i++) {
if (stack_group->stacks[i] == NULL || stack == stack_group->stacks[i]) {
continue;
diff --git a/src/lstack/core/lstack_thread_rpc.c b/src/lstack/core/lstack_thread_rpc.c
index 9f871af..26bd16a 100644
--- a/src/lstack/core/lstack_thread_rpc.c
+++ b/src/lstack/core/lstack_thread_rpc.c
@@ -146,7 +146,6 @@ static struct rpc_msg *rpc_msg_alloc_except(rpc_func_t func)
static void stack_exit_by_rpc(struct rpc_msg *msg)
{
- stack_stop();
stack_exit();
}
diff --git a/src/lstack/include/lstack_protocol_stack.h b/src/lstack/include/lstack_protocol_stack.h
index c7c7efe..c9c50c9 100644
--- a/src/lstack/include/lstack_protocol_stack.h
+++ b/src/lstack/include/lstack_protocol_stack.h
@@ -120,7 +120,7 @@ void thread_bind_stack(struct protocol_stack *stack);
int stack_group_init(void);
void stack_group_exit(void);
void stack_exit(void);
-void stack_stop(void);
+void stack_wait(void);
int stack_setup_thread(void);
int stack_setup_app_thread(void);
--
2.33.0