Browse Source

mproved the processing of background task to enable more advanced functionalities like queuing (protection against reentrance)

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3313 a333f486-631f-4898-b8df-5754b55c2be0
romainq 10 years ago
parent
commit
0bd3679b4c
1 changed files with 11 additions and 4 deletions
  1. 11 4
      core/asynctask.class.inc.php

+ 11 - 4
core/asynctask.class.inc.php

@@ -120,10 +120,17 @@ abstract class AsyncTask extends DBObject
 	{
 	{
 		try
 		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)
 		catch(Exception $e)
 		{
 		{