Replaced "table lock" - it is not so good, it seems

This commit is contained in:
Michael
2017-06-12 14:19:47 +00:00
parent 2372ef7fd5
commit 1932a6d634
3 changed files with 8 additions and 12 deletions

View File

@@ -87,7 +87,7 @@ function poller_run($argv, $argc){
// If we got that queue entry we claim it for us
if (!poller_claim_process($r[0])) {
dba::unlock();
Lock::remove('poller_fetch_worker');
continue;
} else {
// Fetch all workerqueue data while the table is still locked
@@ -95,7 +95,7 @@ function poller_run($argv, $argc){
$entries = poller_total_entries();
$top_priority = poller_highest_priority();
$high_running = poller_process_with_priority_active($top_priority);
dba::unlock();
Lock::remove('poller_fetch_worker');
}
// To avoid the quitting of multiple pollers only one poller at a time will execute the check
@@ -616,9 +616,11 @@ function poller_worker_process() {
// Check if we should pass some low priority process
$highest_priority = 0;
if (poller_passing_slow($highest_priority)) {
dba::lock('workerqueue');
if (!Lock::set('poller_fetch_worker')) {
return false;
}
if (poller_passing_slow($highest_priority)) {
// Are there waiting processes with a higher priority than the currently highest?
$r = q("SELECT * FROM `workerqueue`
WHERE `executed` <= '%s' AND `priority` < %d
@@ -638,8 +640,6 @@ function poller_worker_process() {
if (dbm::is_result($r)) {
return $r;
}
} else {
dba::lock('workerqueue');
}
// If there is no result (or we shouldn't pass lower processes) we check without priority limit
@@ -649,7 +649,7 @@ function poller_worker_process() {
// We only unlock the tables here, when we got no data
if (!dbm::is_result($r)) {
dba::unlock();
Lock::remove('poller_fetch_worker');
}
return $r;
@@ -800,6 +800,7 @@ if (array_search(__file__,get_included_files())===0){
get_app()->end_process();
Lock::remove('poller_worker');
Lock::remove('poller_fetch_worker');
killme();
}