60 lines
1.5 KiB
Diff
60 lines
1.5 KiB
Diff
From ac8f22827e961148a8e469e964d58fe248ba03ce Mon Sep 17 00:00:00 2001
|
|
From: yangchen <yangchen145@huawei.com>
|
|
Date: Wed, 4 Dec 2024 18:00:26 +0800
|
|
Subject: [PATCH] openGauss: fix gs_ctl switchover failed
|
|
|
|
---
|
|
src/lstack/api/lstack_unistd.c | 22 ++++++++++++++++++++++
|
|
1 file changed, 22 insertions(+)
|
|
|
|
diff --git a/src/lstack/api/lstack_unistd.c b/src/lstack/api/lstack_unistd.c
|
|
index 1f78626..e61b0a4 100644
|
|
--- a/src/lstack/api/lstack_unistd.c
|
|
+++ b/src/lstack/api/lstack_unistd.c
|
|
@@ -71,6 +71,24 @@ static void lstack_sig_default_handler(int sig)
|
|
(void)kill(getpid(), sig);
|
|
}
|
|
|
|
+static void pthread_block_sig(int sig)
|
|
+{
|
|
+ sigset_t mask;
|
|
+
|
|
+ sigemptyset(&mask);
|
|
+ sigaddset(&mask, sig);
|
|
+ pthread_sigmask(SIG_BLOCK, &mask, NULL);
|
|
+}
|
|
+
|
|
+static void pthread_unblock_sig(int sig)
|
|
+{
|
|
+ sigset_t mask;
|
|
+
|
|
+ sigemptyset(&mask);
|
|
+ sigaddset(&mask, sig);
|
|
+ pthread_sigmask(SIG_UNBLOCK, &mask, NULL);
|
|
+}
|
|
+
|
|
int lstack_signal_init(void)
|
|
{
|
|
unsigned int i;
|
|
@@ -80,6 +98,8 @@ int lstack_signal_init(void)
|
|
if (signal(SIGPIPE, SIG_IGN) == SIG_ERR) {
|
|
return -1;
|
|
}
|
|
+ pthread_block_sig(SIGUSR1);
|
|
+ pthread_block_sig(SIGUSR2);
|
|
|
|
sigemptyset(&action.sa_mask);
|
|
action.sa_flags = (int)(SA_NODEFER | SA_RESETHAND);
|
|
@@ -119,6 +139,8 @@ pid_t lstack_fork(void)
|
|
pid = posix_api->fork_fn();
|
|
/* child not support lwip */
|
|
if (pid == 0) {
|
|
+ pthread_unblock_sig(SIGUSR1);
|
|
+ pthread_unblock_sig(SIGUSR2);
|
|
posix_api->use_kernel = 1;
|
|
}
|
|
return pid;
|
|
--
|
|
2.33.0
|
|
|