Blame SOURCES/irqbalance-1.0.8-irqbalance-signal-handling-tuning.patch

5f346f
From a37e7a0ab152fe6c88d49d8c99200f4d26672e63 Mon Sep 17 00:00:00 2001
5f346f
From: Petr Holasek <pholasek@redhat.com>
5f346f
Date: Wed, 10 Dec 2014 17:23:30 +0100
5f346f
Subject: [PATCH] irqbalance signal handling tuning
5f346f
5f346f
Added sigaction for SIGTERM, SIGUSR1 and SIGUSR2 using the same handler
5f346f
like SIGINT, i.e. stop and cleanup after finishing of current balancing
5f346f
iteration.
5f346f
5f346f
Signed-off-by: Petr Holasek <pholasek@redhat.com>
5f346f
---
5f346f
 irqbalance.c | 33 +++++++++++++++++++++++----------
5f346f
 1 file changed, 23 insertions(+), 10 deletions(-)
5f346f
5f346f
diff --git a/irqbalance.c b/irqbalance.c
5f346f
index 670e688..f22ecfb 100644
5f346f
--- a/irqbalance.c
5f346f
+++ b/irqbalance.c
5f346f
@@ -238,6 +238,15 @@ static void force_rescan(int signum)
5f346f
 int main(int argc, char** argv)
5f346f
 {
5f346f
 	struct sigaction action, hupaction;
5f346f
+	sigset_t sigset, old_sigset;
5f346f
+
5f346f
+	sigemptyset(&sigset);
5f346f
+	sigaddset(&sigset,SIGINT);
5f346f
+	sigaddset(&sigset,SIGHUP);
5f346f
+	sigaddset(&sigset,SIGTERM);
5f346f
+	sigaddset(&sigset,SIGUSR1);
5f346f
+	sigaddset(&sigset,SIGUSR2);
5f346f
+	sigprocmask(SIG_BLOCK, &sigset, &old_sigset);
5f346f
 
5f346f
 #ifdef HAVE_GETOPT_LONG
5f346f
 	parse_command_line(argc, argv);
5f346f
@@ -290,11 +299,6 @@ int main(int argc, char** argv)
5f346f
 		HZ = 100;
5f346f
 	}
5f346f
 
5f346f
-	action.sa_handler = handler;
5f346f
-	sigemptyset(&action.sa_mask);
5f346f
-	action.sa_flags = 0;
5f346f
-	sigaction(SIGINT, &action, NULL);
5f346f
-
5f346f
 	build_object_tree();
5f346f
 	if (debug_mode)
5f346f
 		dump_object_tree();
5f346f
@@ -324,6 +328,20 @@ int main(int argc, char** argv)
5f346f
 		}
5f346f
 	}
5f346f
 
5f346f
+	action.sa_handler = handler;
5f346f
+	sigemptyset(&action.sa_mask);
5f346f
+	action.sa_flags = 0;
5f346f
+	sigaction(SIGINT, &action, NULL);
5f346f
+	sigaction(SIGTERM, &action, NULL);
5f346f
+	sigaction(SIGUSR1, &action, NULL);
5f346f
+	sigaction(SIGUSR2, &action, NULL);
5f346f
+
5f346f
+	hupaction.sa_handler = force_rescan;
5f346f
+	sigemptyset(&hupaction.sa_mask);
5f346f
+	hupaction.sa_flags = 0;
5f346f
+	sigaction(SIGHUP, &hupaction, NULL);
5f346f
+
5f346f
+	sigprocmask(SIG_SETMASK, &old_sigset, NULL);
5f346f
 
5f346f
 #ifdef HAVE_LIBCAP_NG
5f346f
 	// Drop capabilities
5f346f
@@ -337,11 +355,6 @@ int main(int argc, char** argv)
5f346f
 	parse_proc_interrupts();
5f346f
 	parse_proc_stat();
5f346f
 
5f346f
-	hupaction.sa_handler = force_rescan;
5f346f
-	sigemptyset(&hupaction.sa_mask);
5f346f
-	hupaction.sa_flags = 0;
5f346f
-	sigaction(SIGHUP, &hupaction, NULL);
5f346f
-
5f346f
 	while (keep_going) {
5f346f
 		sleep_approx(SLEEP_INTERVAL);
5f346f
 		log(TO_CONSOLE, LOG_INFO, "\n\n\n-----------------------------------------------------------------------------\n");
5f346f
-- 
5f346f
2.1.0
5f346f