From f0cf9ce5197ad7e49bf1581b8755953de5bca242 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Mon, 28 Sep 2015 21:58:58 +0200 Subject: [PATCH] Prevent double execution --- include/poller.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/include/poller.php b/include/poller.php index 4cb6eb8d58..942fb6eafb 100644 --- a/include/poller.php +++ b/include/poller.php @@ -76,11 +76,18 @@ function poller_run(&$argv, &$argc){ if (poller_too_much_workers()) return; - q("UPDATE `workerqueue` SET `executed` = '%s', `pid` = %d WHERE `id` = %d", + q("UPDATE `workerqueue` SET `executed` = '%s', `pid` = %d WHERE `id` = %d AND `executed` = '0000-00-00 00:00:00'", dbesc(datetime_convert()), intval(getmypid()), intval($r[0]["id"])); + // Assure that there are no tasks executed twice + $id = q("SELECT `id` FROM `workerqueue` WHERE `id` = %d AND `pid` = %d", + intval($r[0]["id"]), + intval(getmypid())); + if (!$id) + continue; + $argv = json_decode($r[0]["parameter"]); $argc = count($argv); -- 2.39.5