Kaynağa Gözat

#723 Cron locking is too restrictive

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@2724 a333f486-631f-4898-b8df-5754b55c2be0
romainq 12 yıl önce
ebeveyn
işleme
e72bd81486
1 değiştirilmiş dosya ile 7 ekleme ve 1 silme
  1. 7 1
      webservices/cron.php

+ 7 - 1
webservices/cron.php

@@ -292,9 +292,15 @@ if (utils::ReadParam('status_only', false, true /* Allow CLI */))
 	exit(0);
 }
 
-$sLockName = 'itop.cron.php';
+// Compute the name of a lock for mysql
+// The name is server-wide
+$oConfig = utils::GetConfig();
+$sLockName = 'itop.cron.'.$oConfig->GetDBName().'_'.$oConfig->GetDBSubname();
 
 $oP->p("Starting: ".time().' ('.date('Y-m-d H:i:s').')');
+
+// CAUTION: using GET_LOCK anytime on the same connexion will RELEASE the lock
+// Todo: invoke GET_LOCK from a dedicated session (encapsulate that into a mutex class)
 $res = CMDBSource::QueryToScalar("SELECT GET_LOCK('$sLockName', 1)");// timeout = 1 second (see also IS_FREE_LOCK)
 if (is_null($res))
 {