From 8fba3c57f5fc7d782a1846f7187b370cd18bfbb8 Mon Sep 17 00:00:00 2001 From: Stefan Schantl Date: Thu, 18 Feb 2016 10:48:11 +0100 Subject: [PATCH] Only process any actions on events if the corresponding parser returns one. Signed-off-by: Stefan Schantl --- guardian | 6 +++--- modules/Parser.pm | 10 ++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) 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; } # -- 2.39.2