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);