$argv = $args;
array_shift($argv);
- dba::lock('workerqueue');
-
$parameters = json_encode($argv);
$found = dba::select('workerqueue', array('id'), array('parameter' => $parameters), array('limit' => 1));
dba::insert('workerqueue', array('parameter' => $parameters, 'created' => $created, 'priority' => $priority));
}
- dba::unlock();
-
// Should we quit and wait for the poller to be called as a cronjob?
if ($dont_fork) {
return;
// 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
$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
// 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
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
// 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;
get_app()->end_process();
Lock::remove('poller_worker');
+ Lock::remove('poller_fetch_worker');
killme();
}
logger("Publish feed to ".$rr["callback_url"], LOGGER_DEBUG);
proc_run(array('priority' => PRIORITY_HIGH, 'created' => $a->queue['created'], 'dont_fork' => true),
'include/pubsubpublish.php', (int)$rr["id"]);
- logger("Publish feed to ".$rr["callback_url"].' - done', LOGGER_DEBUG);
}
}