From: Stefan Schantl Date: Thu, 18 Feb 2016 09:48:11 +0000 (+0100) Subject: Only process any actions on events if the corresponding parser returns one. X-Git-Tag: 2.0~27 X-Git-Url: http://git.ipfire.org/?p=people%2Fstevee%2Fguardian.git;a=commitdiff_plain;h=8fba3c57f5fc7d782a1846f7187b370cd18bfbb8 Only process any actions on events if the corresponding parser returns one. Signed-off-by: Stefan Schantl --- diff --git a/guardian b/guardian index c1bf4ca..9b57114 100644 --- 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. diff --git a/modules/Parser.pm b/modules/Parser.pm index 9c3fc87..13715e0 100644 --- a/modules/Parser.pm +++ b/modules/Parser.pm @@ -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; } #