]> git.ipfire.org Git - people/stevee/guardian.git/commitdiff
Only process any actions on events if the corresponding parser returns one.
authorStefan Schantl <stefan.schantl@ipfire.org>
Thu, 18 Feb 2016 09:48:11 +0000 (10:48 +0100)
committerStefan Schantl <stefan.schantl@ipfire.org>
Thu, 18 Feb 2016 09:48:11 +0000 (10:48 +0100)
Signed-off-by: Stefan Schantl <stefan.schantl@ipfire.org>
guardian
modules/Parser.pm

index c1bf4caa31593a8350205ff116f8430583b196ea..9b571145c57b83812db4144c81bcf26ad320262f 100644 (file)
--- a/guardian
+++ b/guardian
@@ -248,16 +248,16 @@ sub Worker ($) {
 
                        # Send filename and message to the parser,
                        # which will return if an action has to be performed.
-                       my @action = &Guardian::Parser::Parser("$parser", @message);
+                       my $action = &Guardian::Parser::Parser("$parser", @message);
 
                        # Send the action to the main process and put it into
                        # the queue.
-                       if (@action) {
+                       if (defined ($action)) {
                                # Lock the queue.
                                lock($queue);
 
                                # Put the required action into the queue.
-                               $queue->enqueue(@action);
+                               $queue->enqueue($action);
                        }
                } else {
                        # Sleep for 10ms until the next round of the loop will start.
index 9c3fc87130204d8bbb674a4afdb7eecb2c0041d2..13715e004dcd7fe5d8115e6d492c463b8fe32dc7 100644 (file)
@@ -30,8 +30,14 @@ sub Parser ($$) {
        # Call responsible message parser.
        my $action = $logfile_parsers{$parser}->(@message);
 
-       # Return which action should be performed.
-       return "count $action";
+       # In case an action has been returned, return it too. 
+       if (defined($action)) {
+               # Return which action should be performed.
+               return "count $action";
+       }
+
+       # Return undef, no action required.
+       return undef;
 }
 
 #