Blame SOURCES/bz1536219-2-logging-Close-before-and-open-blackbox-after-fork.patch

b69418
From 995ed0bd814ff3eacf6c09534841e6ce39ab6614 Mon Sep 17 00:00:00 2001
b69418
From: Jan Friesse <jfriesse@redhat.com>
b69418
Date: Mon, 22 Jan 2018 11:17:52 +0100
b69418
Subject: [PATCH] logging: Close before and open blackbox after fork
b69418
b69418
Signed-off-by: Jan Friesse <jfriesse@redhat.com>
b69418
Reviewed-by: Christine Caulfield <ccaulfie@redhat.com>
b69418
(cherry picked from commit 11fa527ed4960488d275867c28b1bff773e9cf7f)
b69418
---
b69418
 exec/logsys.c             |   16 ++++++++++++++++
b69418
 exec/main.c               |    6 ++++++
b69418
 include/corosync/logsys.h |    5 +++++
b69418
 3 files changed, 27 insertions(+), 0 deletions(-)
b69418
b69418
diff --git a/exec/logsys.c b/exec/logsys.c
b69418
index a38cc5e..8c9c222 100644
b69418
--- a/exec/logsys.c
b69418
+++ b/exec/logsys.c
b69418
@@ -862,3 +862,19 @@ void logsys_blackbox_set(int enable)
b69418
 
b69418
 	pthread_mutex_unlock (&logsys_config_mutex);
b69418
 }
b69418
+
b69418
+/*
b69418
+ * To set correct pid to qb blackbox filename after tty dettach (fork) we have to
b69418
+ * close (this function) and (if needed) reopen blackbox (logsys_blackbox_postfork function).
b69418
+ */
b69418
+void logsys_blackbox_prefork(void)
b69418
+{
b69418
+
b69418
+	(void)qb_log_ctl(QB_LOG_BLACKBOX, QB_LOG_CONF_ENABLED, QB_FALSE);
b69418
+}
b69418
+
b69418
+void logsys_blackbox_postfork(void)
b69418
+{
b69418
+
b69418
+	_logsys_config_apply_blackbox();
b69418
+}
b69418
diff --git a/exec/main.c b/exec/main.c
b69418
index cd587dc..426e56d 100644
b69418
--- a/exec/main.c
b69418
+++ b/exec/main.c
b69418
@@ -1460,7 +1460,13 @@ int main (int argc, char **argv, char **envp)
b69418
 	 * Now we are fully initialized.
b69418
 	 */
b69418
 	if (background) {
b69418
+		logsys_blackbox_prefork();
b69418
+
b69418
 		corosync_tty_detach ();
b69418
+
b69418
+		logsys_blackbox_postfork();
b69418
+
b69418
+		log_printf (LOGSYS_LEVEL_DEBUG, "Corosync TTY detached");
b69418
 	}
b69418
 
b69418
 	/*
b69418
diff --git a/include/corosync/logsys.h b/include/corosync/logsys.h
b69418
index ec38d2c..a4aad69 100644
b69418
--- a/include/corosync/logsys.h
b69418
+++ b/include/corosync/logsys.h
b69418
@@ -258,6 +258,11 @@ extern int logsys_thread_start (void);
b69418
 
b69418
 extern void logsys_blackbox_set(int enable);
b69418
 
b69418
+extern void logsys_blackbox_prefork(void);
b69418
+
b69418
+extern void logsys_blackbox_postfork(void);
b69418
+
b69418
+
b69418
 /**
b69418
  * @brief logsys_subsys_id
b69418
  */
b69418
-- 
b69418
1.7.1
b69418