From 9dd4b058660d8626364446af7627f3fadeb07ffe Mon Sep 17 00:00:00 2001 From: Romain Quetiez Date: Wed, 3 Sep 2014 09:56:44 +0000 Subject: [PATCH] Improved the processing of background task to enable more advanced functionalities like queuing (protection against reentrance) -reintegrated from trunk SVN:2.0.3[3314] --- core/asynctask.class.inc.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/core/asynctask.class.inc.php b/core/asynctask.class.inc.php index 74bb54479d..25f54c76e8 100644 --- a/core/asynctask.class.inc.php +++ b/core/asynctask.class.inc.php @@ -120,10 +120,17 @@ abstract class AsyncTask extends DBObject { try { - $this->Set('status', 'running'); - $this->Set('started', time()); - $this->DBUpdate(); - return self::OK; + if ($this->Get('status') == 'running') + { + return self::ALREADY_RUNNING; + } + else + { + $this->Set('status', 'running'); + $this->Set('started', time()); + $this->DBUpdate(); + return self::OK; + } } catch(Exception $e) {