Merge branch 'ent-4153-threads-shared' into 'develop'

threads-shared returns

See merge request 
This commit is contained in:
Daniel Rodriguez 2019-06-06 13:31:12 +02:00
commit 75872850ce
2 changed files with 28 additions and 23 deletions
pandora_server/lib/PandoraFMS

View File

@ -4859,6 +4859,8 @@ sub pandora_process_policy_queue ($) {
logger($pa_config, "Starting policy queue patrol process.", 1); logger($pa_config, "Starting policy queue patrol process.", 1);
while($THRRUN == 1) { while($THRRUN == 1) {
eval {{
local $SIG{__DIE__};
# If we are not the master server sleep and check again. # If we are not the master server sleep and check again.
if (pandora_is_master($pa_config) == 0) { if (pandora_is_master($pa_config) == 0) {
@ -4866,9 +4868,6 @@ sub pandora_process_policy_queue ($) {
next; next;
} }
# Check the queue each 5 seconds
sleep (5);
my $operation = enterprise_hook('get_first_policy_queue', [$dbh]); my $operation = enterprise_hook('get_first_policy_queue', [$dbh]);
next unless (defined ($operation) && $operation ne ''); next unless (defined ($operation) && $operation ne '');
@ -4885,6 +4884,11 @@ sub pandora_process_policy_queue ($) {
} }
enterprise_hook('pandora_finish_queue_operation', [$dbh, $operation->{'id'}]); enterprise_hook('pandora_finish_queue_operation', [$dbh, $operation->{'id'}]);
}};
# Check the queue each 5 seconds
sleep(5);
} }
db_disconnect($dbh); db_disconnect($dbh);

View File

@ -29,6 +29,7 @@ use Sys::Syslog;
use Scalar::Util qw(looks_like_number); use Scalar::Util qw(looks_like_number);
use LWP::UserAgent; use LWP::UserAgent;
use threads; use threads;
use threads::shared;
# New in 3.2. Used to sendmail internally, without external scripts # New in 3.2. Used to sendmail internally, without external scripts
# use Module::Loaded; # use Module::Loaded;
@ -1864,7 +1865,7 @@ sub stop_server_threads {
$THRRUN = 0; $THRRUN = 0;
foreach my $thr (@ServerThreads) { foreach my $thr (@ServerThreads) {
$thr->detach(); $thr->join();
} }
@ServerThreads = (); @ServerThreads = ();