Trying to protect the Synchro for timeouts, since the synchro may be launched from the web (as a "web service", especially by the "collectors"). To be validated further with large amounts of data.

SVN:trunk[4210]
This commit is contained in:
Denis Flaven
2016-06-14 16:11:28 +00:00
parent 304080d74d
commit d88249eabc
2 changed files with 14 additions and 2 deletions

View File

@@ -491,11 +491,14 @@ try
// Prepare insert columns
$sInsertColumns = '`'.implode('`, `', $aInputColumns).'`';
$iPreviousTimeLimit = ini_get('max_execution_time');
$iLoopTimeLimit = MetaModel::GetConfig()->Get('max_execution_time_per_loop');
$oMutex = new iTopMutex('synchro_import_'.$oDataSource->GetKey());
$oMutex->Lock();
foreach($aData as $iRow => $aRow)
{
$sReconciliationCondition = "`primary_key` = ".CMDBSource::Quote($aRow[$iPrimaryKeyCol]);
set_time_limit($iLoopTimeLimit);
$sReconciliationCondition = "`primary_key` = ".CMDBSource::Quote($aRow[$iPrimaryKeyCol]);
$sSelect = "SELECT COUNT(*) FROM `$sTable` WHERE $sReconciliationCondition";
$aRes = CMDBSource::QueryToArray($sSelect);
$iCount = $aRes[0]['COUNT(*)'];
@@ -632,6 +635,7 @@ try
}
}
$oMutex->Unlock();
set_time_limit($iPreviousTimeLimit);
if (($sOutput == "summary") || ($sOutput == 'details'))
{