From aeb4e8edfc552d6b235e25c35d0b4c8e68440473 Mon Sep 17 00:00:00 2001 From: ramonn Date: Fri, 5 Aug 2011 10:23:22 +0000 Subject: [PATCH] 2011-08-05 Ramon Novoa * lib/PandoraFMS/Core.pm: Changed the return value of get_first_policy_queue. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4677 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_server/ChangeLog | 5 +++++ pandora_server/lib/PandoraFMS/Core.pm | 30 +++++++++++++-------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/pandora_server/ChangeLog b/pandora_server/ChangeLog index 1be3d49819..41a229ef6a 100644 --- a/pandora_server/ChangeLog +++ b/pandora_server/ChangeLog @@ -1,3 +1,8 @@ +2011-08-05 Ramon Novoa + + * lib/PandoraFMS/Core.pm: Changed the return value of + get_first_policy_queue. + 2011-08-05 Koichiro KIKUCHI * pandora_server.redhat.spec: Updated dependecies. Removed perl-XML-SAX diff --git a/pandora_server/lib/PandoraFMS/Core.pm b/pandora_server/lib/PandoraFMS/Core.pm index 3676fdc154..3afc690d7f 100644 --- a/pandora_server/lib/PandoraFMS/Core.pm +++ b/pandora_server/lib/PandoraFMS/Core.pm @@ -2228,23 +2228,21 @@ sub pandora_process_policy_queue ($) { while(1) { my $operation = enterprise_hook('get_first_policy_queue', [$dbh]); - $operation = @{$operation}[0]; - - if(defined($operation)) { - if($operation->{'operation'} eq 'apply' || $operation->{'operation'} eq 'apply_db') { - enterprise_hook('pandora_apply_policy', [$dbh, $pa_config, $operation->{'id_policy'}, $operation->{'id_agent'}, $operation->{'id'}, $operation->{'operation'}]); - } - elsif($operation->{'operation'} eq 'delete') { - if($operation->{'id_agent'} == 0) { - enterprise_hook('pandora_purge_policy_agents', [$dbh, $pa_config, $operation->{'id_policy'}]); - } - else { - enterprise_hook('pandora_delete_agent_from_policy', [$dbh, $pa_config, $operation->{'id_policy'}, $operation->{'id_agent'}]); - } - } - - enterprise_hook('pandora_finish_queue_operation', [$dbh, $operation->{'id'}]); + next unless (defined ($operation) && $operation ne ''); + + if($operation->{'operation'} eq 'apply' || $operation->{'operation'} eq 'apply_db') { + enterprise_hook('pandora_apply_policy', [$dbh, $pa_config, $operation->{'id_policy'}, $operation->{'id_agent'}, $operation->{'id'}, $operation->{'operation'}]); } + elsif($operation->{'operation'} eq 'delete') { + if($operation->{'id_agent'} == 0) { + enterprise_hook('pandora_purge_policy_agents', [$dbh, $pa_config, $operation->{'id_policy'}]); + } + else { + enterprise_hook('pandora_delete_agent_from_policy', [$dbh, $pa_config, $operation->{'id_policy'}, $operation->{'id_agent'}]); + } + } + + enterprise_hook('pandora_finish_queue_operation', [$dbh, $operation->{'id'}]); # Check the queue each 5 seconds sleep (5);