Merge branch 'ent-4153-threads-shared' into 'develop'
threads-shared returns See merge request artica/pandorafms!2480
This commit is contained in:
commit
75872850ce
|
@ -4859,32 +4859,36 @@ sub pandora_process_policy_queue ($) {
|
|||
logger($pa_config, "Starting policy queue patrol process.", 1);
|
||||
|
||||
while($THRRUN == 1) {
|
||||
eval {{
|
||||
local $SIG{__DIE__};
|
||||
|
||||
# If we are not the master server sleep and check again.
|
||||
if (pandora_is_master($pa_config) == 0) {
|
||||
sleep ($pa_config->{'server_threshold'});
|
||||
next;
|
||||
}
|
||||
# If we are not the master server sleep and check again.
|
||||
if (pandora_is_master($pa_config) == 0) {
|
||||
sleep ($pa_config->{'server_threshold'});
|
||||
next;
|
||||
}
|
||||
|
||||
my $operation = enterprise_hook('get_first_policy_queue', [$dbh]);
|
||||
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);
|
||||
sleep(5);
|
||||
|
||||
my $operation = enterprise_hook('get_first_policy_queue', [$dbh]);
|
||||
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'}]);
|
||||
}
|
||||
|
||||
db_disconnect($dbh);
|
||||
|
|
|
@ -29,6 +29,7 @@ use Sys::Syslog;
|
|||
use Scalar::Util qw(looks_like_number);
|
||||
use LWP::UserAgent;
|
||||
use threads;
|
||||
use threads::shared;
|
||||
|
||||
# New in 3.2. Used to sendmail internally, without external scripts
|
||||
# use Module::Loaded;
|
||||
|
@ -1864,7 +1865,7 @@ sub stop_server_threads {
|
|||
$THRRUN = 0;
|
||||
|
||||
foreach my $thr (@ServerThreads) {
|
||||
$thr->detach();
|
||||
$thr->join();
|
||||
}
|
||||
|
||||
@ServerThreads = ();
|
||||
|
|
Loading…
Reference in New Issue