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