Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion data-sources/datasource.remote.php
Original file line number Diff line number Diff line change
Expand Up @@ -851,13 +851,15 @@ public function execute(array &$param_pool = null)
$writeToCache = null;
$isCacheValid = true;
$creation = DateTimeObj::get('c');
$mutexRetrySleepTime = 1; //in secondes
$mutexRetryCount = 50;

// Execute if the cache doesn't exist, or if it is old.
if (
(!is_array($cachedData) || empty($cachedData)) // There's no cache.
|| (time() - $cachedData['creation']) > ($this->dsParamCACHE * 60) // The cache is old.
) {
if (Mutex::acquire($cache_id, $this->dsParamTIMEOUT, TMP)) {
if (Mutex::acquireOrWait($cache_id, $this->dsParamTIMEOUT, TMP, $mutexRetryCount, $mutexRetrySleepTime)) {
list($data, $info) = self::fetch($this->dsParamURL, $this->dsParamFORMAT, $this->dsParamTIMEOUT);
Mutex::release($cache_id, TMP);
$writeToCache = true;
Expand Down Expand Up @@ -924,6 +926,7 @@ public function execute(array &$param_pool = null)
$result->appendChild(
new XMLElement('error', __('The %s class failed to acquire a lock.', array('<code>Mutex</code>')))
);
Symphony::log()->pushToLog(__('The %s class failed to acquire a mutex lock after %s retry.', array('<code>datasource.remote</code>', $mutexRetryCount)), E_ERROR, true);
}

// The cache is good, use it!
Expand Down