threads-shared returns

This commit is contained in:
fbsanchez 2019-06-04 15:10:05 +02:00
parent c584367c14
commit b7c14d49fd
2 changed files with 28 additions and 23 deletions

View File

@ -4859,6 +4859,8 @@ 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) {
@ -4866,9 +4868,6 @@ sub pandora_process_policy_queue ($) {
next;
}
# Check the queue each 5 seconds
sleep (5);
my $operation = enterprise_hook('get_first_policy_queue', [$dbh]);
next unless (defined ($operation) && $operation ne '');
@ -4885,6 +4884,11 @@ sub pandora_process_policy_queue ($) {
}
enterprise_hook('pandora_finish_queue_operation', [$dbh, $operation->{'id'}]);
}};
# Check the queue each 5 seconds
sleep(5);
}
db_disconnect($dbh);

View File

@ -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 = ();