From 47b8975bb6f59c09dc28f7d08a87c51fd2e197da Mon Sep 17 00:00:00 2001
From: Michael Vogel <ike@pirati.ca>
Date: Sun, 23 Oct 2016 23:31:56 +0000
Subject: [PATCH] poller.php is now working with transactions as well.

---
 include/poller.php | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/include/poller.php b/include/poller.php
index bbec43ae7b..2e036247e2 100644
--- a/include/poller.php
+++ b/include/poller.php
@@ -98,6 +98,7 @@ function poller_run(&$argv, &$argc){
 
 		if (!$upd) {
 			logger("Couldn't update queue entry ".$r[0]["id"]." - skip this execution", LOGGER_DEBUG);
+			q("COMMIT");
 			continue;
 		}
 
@@ -105,14 +106,18 @@ function poller_run(&$argv, &$argc){
 		$id = q("SELECT `pid`, `executed` FROM `workerqueue` WHERE `id` = %d", intval($r[0]["id"]));
 		if (!$id) {
 			logger("Queue item ".$r[0]["id"]." vanished - skip this execution", LOGGER_DEBUG);
+			q("COMMIT");
 			continue;
 		} elseif ((strtotime($id[0]["executed"]) <= 0) OR ($id[0]["pid"] == 0)) {
-			logger("Entry for queue item ".$r[0]["id"]." wasn't stored - we better stop here", LOGGER_DEBUG);
-			return;
+			logger("Entry for queue item ".$r[0]["id"]." wasn't stored - skip this execution", LOGGER_DEBUG);
+			q("COMMIT");
+			continue;
 		} elseif ($id[0]["pid"] != $mypid) {
 			logger("Queue item ".$r[0]["id"]." is to be executed by process ".$id[0]["pid"]." and not by me (".$mypid.") - skip this execution", LOGGER_DEBUG);
+			q("COMMIT");
 			continue;
 		}
+		q("COMMIT");
 
 		$argv = json_decode($r[0]["parameter"]);
 
@@ -433,6 +438,8 @@ function poller_passing_slow(&$highest_priority) {
 
 function poller_worker_process() {
 
+	q("START TRANSACTION;");
+
 	// Check if we should pass some low priority process
 	$highest_priority = 0;
 
-- 
2.39.5