#723 Cron locking is too restrictive

SVN:trunk[2724]
This commit is contained in:
Romain Quetiez
2013-05-14 09:34:08 +00:00
parent ed344650c5
commit 7cae338e6d

View File

@@ -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))
{