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 c1bf4ca..9b57114 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 9c3fc87..13715e0 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;
 }
 
 #