- // If we got that queue entry we claim it for us
- if (!poller_claim_process($r[0])) {
- dba::unlock();
- continue;
- } else {
- // Fetch all workerqueue data while the table is still locked
- // This is redundant, but this speeds up the processing
- $entries = poller_total_entries();
- $top_priority = poller_highest_priority();
- $high_running = poller_process_with_priority_active($top_priority);
- dba::unlock();
+ foreach ($r AS $entry) {
+ // Assure that the priority is an integer value
+ $entry['priority'] = (int)$entry['priority'];
+
+ // The work will be done
+ if (!poller_execute($entry)) {
+ logger('Process execution failed, quitting.', LOGGER_DEBUG);
+ return;
+ }
+
+ // If possible we will fetch new jobs for this worker
+ if (!$refetched && Lock::set('poller_worker_process', 0)) {
+ $stamp = (float)microtime(true);
+ $refetched = find_worker_processes();
+ $poller_db_duration += (microtime(true) - $stamp);
+ Lock::remove('poller_worker_process');
+ }