We found the handbrake ...

This commit is contained in:
Michael 2017-06-05 22:41:33 +00:00
parent 2bff8e302a
commit 2b04865cdb
2 changed files with 9 additions and 14 deletions

View file

@ -89,21 +89,16 @@ function poller_run($argv, $argc){
continue; continue;
} }
// To avoid the quitting of multiple pollers we serialize the next check // To avoid the quitting of multiple pollers only one poller at a time will execute the check
if (!Lock::set('poller_worker')) { if (Lock::set('poller_worker', 0)) {
logger('Cannot get a lock, retrying.', LOGGER_DEBUG); // Count active workers and compare them with a maximum value that depends on the load
poller_unclaim_process(); if (poller_too_much_workers()) {
continue; logger('Active worker limit reached, quitting.', LOGGER_DEBUG);
return;
}
Lock::remove('poller_worker');
} }
// Count active workers and compare them with a maximum value that depends on the load
if (poller_too_much_workers()) {
logger('Active worker limit reached, quitting.', LOGGER_DEBUG);
return;
}
Lock::remove('poller_worker');
// Check free memory // Check free memory
if ($a->min_memory_reached()) { if ($a->min_memory_reached()) {
logger('Memory limit reached, quitting.', LOGGER_DEBUG); logger('Memory limit reached, quitting.', LOGGER_DEBUG);

View file

@ -79,7 +79,7 @@ class Lock {
if (!$got_lock) { if (!$got_lock) {
usleep($wait_sec * 1000000); usleep($wait_sec * 1000000);
} }
} while (!$got_lock AND ((time(true) - $start) < $timeout)); } while (!$got_lock AND ((time() - $start) < $timeout));
return $got_lock; return $got_lock;
} }