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