]> git.ipfire.org Git - people/stevee/ipfire-2.x.git/commitdiff
guardian: Handle sighup signals.
authorStefan Schantl <stefan.schantl@ipfire.org>
Thu, 16 Oct 2014 19:53:33 +0000 (21:53 +0200)
committerStefan Schantl <stefan.schantl@ipfire.org>
Thu, 16 Oct 2014 19:53:33 +0000 (21:53 +0200)
We now can capture and handle sighup signals, to perform a reload
of the config file, re-read the ignorefile and recreate the ignorehash and
finally to grab possible alias addresses from red and re-add them to the ignorehash.

config/guardian/guardian.pl

index 82580a925c134755808e964a9557ede6a10bb588..69bf96fc08564e51903098f1b44f1742a683260f 100644 (file)
@@ -143,7 +143,7 @@ while () {
        my $current_elements = $queue->pending();
 
        # Check if our queue contains some elements.
-       if (defined($current_elements)) {
+       if ($current_elements > 0) {
                # Grab element data from queue.
                my $element = $queue->peek();
 
@@ -615,7 +615,24 @@ sub sig_handler_setup {
        $SIG{INT} = \&clean_up_and_exit; # kill -2
        $SIG{TERM} = \&clean_up_and_exit; # kill -9
        $SIG{QUIT} = \&clean_up_and_exit; # kill -3
-#  $SIG{HUP} = \&flush_and_reload; # kill -1
+       $SIG{HUP} = \&reload_on_sighup; # kill -1
+}
+
+#
+## Function to handle sighup events.
+#
+sub reload_on_sighup {
+       # Print out log message.
+       &logger("info", "Recived SIGHUP signal - Reloading configfile and recreate the ignorelist.\n");
+
+       # Reload config file.
+       &load_conf;
+
+       # Rebuild ignorehash.
+       &build_ignore_hash;
+
+       # Grab alias adresses on red.
+       &get_aliases;
 }
 
 #
@@ -673,7 +690,7 @@ sub call_unblock ($) {
 #
 ## Subroutine to handle shutdown of the programm.
 sub clean_up_and_exit {
-       &logger("debug", "received kill sig.. shutting down\n");
+       &logger("debug", "Received KILL signal - Shutting down\n");
 
        # Unblock all currently blocked addresses.
        foreach my $address (keys %blockhash) {