device-mapper-multipath/0055-multipathd-add-cleanup_child-exit-handler.patch
DistroBaker 28d3ae407e Merged update from upstream sources
This is an automated DistroBaker update from upstream sources.
If you do not know what this is about or would like to opt out,
contact the OSCI team.

Source: https://src.fedoraproject.org/rpms/device-mapper-multipath.git#26a2cd7a3e189bf91263d17bc8a8c449cc043fb0
2021-01-21 16:56:27 +00:00

96 lines
2.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Martin Wilck <mwilck@suse.com>
Date: Wed, 23 Sep 2020 21:08:19 +0200
Subject: [PATCH] multipathd: add cleanup_child() exit handler
cleanup_child() calls all cleanups in the right order, in an
exit handler.
Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
---
multipathd/main.c | 45 +++++++++++++++++++++++++--------------------
1 file changed, 25 insertions(+), 20 deletions(-)
diff --git a/multipathd/main.c b/multipathd/main.c
index 4c4e2eab..50cc3356 100644
--- a/multipathd/main.c
+++ b/multipathd/main.c
@@ -3024,6 +3024,27 @@ static void cleanup_rcu(void)
rcu_unregister_thread();
}
+static void cleanup_child(void)
+{
+ cleanup_threads();
+ cleanup_vecs();
+ cleanup_foreign();
+ cleanup_checkers();
+ cleanup_prio();
+ if (poll_dmevents)
+ cleanup_dmevent_waiter();
+
+ cleanup_pidfile();
+ if (logsink == 1)
+ log_thread_stop();
+
+ cleanup_conf();
+
+#ifdef _DEBUG_
+ dbg_free_final(NULL);
+#endif
+}
+
static int sd_notify_exit(int err)
{
#ifdef USE_SYSTEMD
@@ -3049,7 +3070,9 @@ child (__attribute__((unused)) void *param)
mlockall(MCL_CURRENT | MCL_FUTURE);
signal_init();
mp_rcu_data = setup_rcu();
- atexit(cleanup_rcu);
+
+ if (atexit(cleanup_rcu) || atexit(cleanup_child))
+ fprintf(stderr, "failed to register cleanup handlers\n");
setup_thread_attr(&misc_attr, 64 * 1024, 0);
setup_thread_attr(&uevent_attr, DEFAULT_UEVENT_STACKSIZE * 1024, 0);
@@ -3063,8 +3086,6 @@ child (__attribute__((unused)) void *param)
pid_fd = pidfile_create(DEFAULT_PIDFILE, daemon_pid);
if (pid_fd < 0) {
condlog(1, "failed to create pidfile");
- if (logsink == 1)
- log_thread_stop();
exit(1);
}
@@ -3212,24 +3233,8 @@ child (__attribute__((unused)) void *param)
exit_code = 0;
failed:
- cleanup_threads();
- cleanup_vecs();
- cleanup_foreign();
- cleanup_checkers();
- cleanup_prio();
- if (poll_dmevents)
- cleanup_dmevent_waiter();
-
- /* We're done here */
- cleanup_pidfile();
condlog(2, "--------shut down-------");
-
- if (logsink == 1)
- log_thread_stop();
- cleanup_conf();
-#ifdef _DEBUG_
- dbg_free_final(NULL);
-#endif
+ /* All cleanup is done in the cleanup_child() exit handler */
return sd_notify_exit(exit_code);
}
--
2.17.2