代码拉取完成,页面将自动刷新
同步操作将从 src-anolis-os/systemd 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
From 64072aab92ff6489a2e460a9bdd1cfefa587264b Mon Sep 17 00:00:00 2001
From: Yuanhong Peng <yummypeng@linux.alibaba.com>
Date: Tue, 19 Apr 2022 13:36:09 +0800
Subject: [PATCH] Do not go into freeze when systemd crashd
---
src/core/main.c | 41 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 40 insertions(+), 1 deletion(-)
diff --git a/src/core/main.c b/src/core/main.c
index 0aec5d1..db91151 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -3,6 +3,7 @@
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
+#include <setjmp.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
@@ -10,6 +11,7 @@
#include <sys/prctl.h>
#include <sys/reboot.h>
#include <sys/stat.h>
+#include <sys/wait.h>
#include <unistd.h>
#if HAVE_SECCOMP
#include <seccomp.h>
@@ -135,10 +137,41 @@ static sd_id128_t arg_machine_id;
static EmergencyAction arg_cad_burst_action;
static CPUSet arg_cpu_affinity;
static NUMAPolicy arg_numa_policy;
+static bool reexec_jmp_can = false;
+static bool reexec_jmp_inited = false;
+static sigjmp_buf reexec_jmp_buf;
static int parse_configuration(const struct rlimit *saved_rlimit_nofile,
const struct rlimit *saved_rlimit_memlock);
+static void reexec_handler(int sig) {
+ reexec_jmp_can = true;
+}
+
+_noreturn_ static void freeze_wait_upgrade(void) {
+ struct sigaction sa;
+ sigset_t ss;
+
+ sigemptyset(&ss);
+ sigaddset(&ss, SIGTERM);
+ sigprocmask(SIG_UNBLOCK, &ss, NULL);
+
+ sa.sa_handler = reexec_handler;
+ sa.sa_flags = SA_RESTART;
+ sigaction(SIGTERM, &sa, NULL);
+
+ log_error("freeze_wait_upgrade: %d\n", reexec_jmp_inited);
+ reexec_jmp_can = false;
+ while(1) {
+ usleep(10000);
+ if (reexec_jmp_inited && reexec_jmp_can) {
+ log_error("goto manager_reexecute.\n");
+ siglongjmp(reexec_jmp_buf, 1);
+ }
+ waitpid(-1, NULL, WNOHANG);
+ }
+}
+
_noreturn_ static void freeze_or_exit_or_reboot(void) {
/* If we are running in a contianer, let's prefer exiting, after all we can propagate an exit code to the
* container manager, and thus inform it that something went wrong. */
@@ -157,7 +190,8 @@ _noreturn_ static void freeze_or_exit_or_reboot(void) {
}
log_emergency("Freezing execution.");
- freeze();
+ freeze_wait_upgrade();
+
}
_noreturn_ static void crash(int sig) {
@@ -1667,6 +1701,10 @@ static int invoke_main_loop(
assert(ret_switch_root_init);
assert(ret_error_message);
+ reexec_jmp_inited = true;
+ if (sigsetjmp(reexec_jmp_buf, 1))
+ goto manager_reexecute;
+
for (;;) {
r = manager_loop(m);
if (r < 0) {
@@ -1709,6 +1747,7 @@ static int invoke_main_loop(
case MANAGER_REEXECUTE:
+manager_reexecute:
r = prepare_reexecute(m, &arg_serialization, ret_fds, false);
if (r < 0) {
*ret_error_message = "Failed to prepare for reexecution";
--
2.27.0
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。