]> git.mxchange.org Git - friendica.git/commitdiff
Prevent double execution
authorMichael Vogel <icarus@dabo.de>
Mon, 28 Sep 2015 19:58:58 +0000 (21:58 +0200)
committerMichael Vogel <icarus@dabo.de>
Mon, 28 Sep 2015 19:58:58 +0000 (21:58 +0200)
include/poller.php

index 4cb6eb8d584c4516482321d25f711cd56fcec936..942fb6eafb248bd44169d2812e4a84259cfe52aa 100644 (file)
@@ -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);