Project

General

Profile

Feature #18557 » 0008010.patch

Administrator Admin, 2008-04-03 18:14

View differences:

t3lib/class.t3lib_db.php (Arbeitskopie)
return $wgolParts;
}
/**
* Tries to obtain a lock with a name given by the string $name with an optional timeout in seconds.
*
* Return values:
* - 1: the lock was obtained successfully
* - 0: the attempt timed out (because lock existed before and was not released withing the timeout)
* - null: an error occurred
*
* @param string $name: Name identifying the lock
* @param integer $timeout: Timeout for the attempt to obtain a lock
* @return mixed Returns 1 if the lock was obtained or 0/null if not (see method comment for more details)
*/
public function getLock($name, $timeout=0) {
$timeout = intval($timeout);
$resource = $this->sql_query('SELECT GET_LOCK('.$this->fullQuoteStr($name, '_DEFAULT').($timeout>0 ? ', '.$timeout : '').')');
if (is_resource($resource)) {
list($result) = $this->sql_fetch_row($resource);
$this->sql_free_result($resource);
}
return $result;
}
/**
* Releases the lock named by the string $name that was obtained with getLock().
*
* Return values:
* - 1: the lock was released
* - 0: the lock was not established by this thread and thus cannot be released
* - null: the named lock did not exist
*
* @param string $name: Name identifying the lock
* @return mixed Returns 1 if the lock was released or 0/null if not (see method comment for more details)
*/
public function releaseLock($name) {
$resource = $this->sql_query('SELECT RELEASE_LOCK('.$this->fullQuoteStr($name, '_DEFAULT').')');
if (is_resource($resource)) {
list($result) = $this->sql_fetch_row($resource);
$this->sql_free_result($resource);
}
return $result;
}
/**
* Checkes whether the lock named by the string $name is free to use and thus not locked.
*
* Return values:
* - 1: the lock is free
* - 0: the lock is in use
* - null: an error occurred
*
* @param string $name: Name identifying the lock
* @return mixed Returns 1 if the lock is free or 0/null if not (see method comment for more details)
*/
public function isFreeLock($name) {
$resource = $this->sql_query('SELECT IS_FREE_LOCK('.$this->fullQuoteStr($name, '_DEFAULT').')');
if (is_resource($resource)) {
list($result) = $this->sql_fetch_row($resource);
$this->sql_free_result($resource);
}
return $result;
}
......
/**************************************
*
* MySQL wrapper functions
t3lib/class.t3lib_lock.php (Arbeitskopie)
$success = true;
}
break;
case 'database':
$this->resource = $this->id = md5($id);
$success = true;
break;
case 'disable':
return false;
break;
......
$noWait = false;
}
break;
case 'database':
$result = $GLOBALS['TYPO3_DB']->getLock($this->resource, $this->loops*$this->step);
if (!$result) {
if (isset($result)) {
$this->sysLog('Trying to acquire the lock timed out');
} else {
$this->sysLog('An error occurred while trying to acquire the lock', 3);
}
$noWait = false;
$isAcquired = false;
}
break;
case 'disable':
$noWait = false;
$isAcquired = false;
......
$success = false;
}
break;
case 'database':
$result = $GLOBALS['TYPO3_DB']->releaseLock($this->resource);
if (!$result) {
if (isset($result)) {
$this->sysLog('Could not release a lock which is owned by another process');
$success = false;
} else {
$this->sysLog('The lock to be released did not exist (anymore)');
}
}
break;
case 'disable':
$success = false;
break;
typo3/sysext/cms/tslib/class.tslib_fe.php (Arbeitskopie)
*/
function releasePageGenerationLock(&$lockObj) {
$success = false;
// If lock object is set and was aquired (may also happen if no_cache was enabled during runtime), release it:
// If lock object is set and was acquired (may also happen if no_cache was enabled during runtime), release it:
if (is_object($lockObj) && $lockObj instanceof t3lib_lock && $lockObj->getLockStatus()) {
$success = $lockObj->release();
$lockObj->sysLog('Released lock');
(2-2/4)