0008010.patch

Administrator Admin, 2008-04-03 18:14

Download (4.71 KB)

View differences:

t3lib/class.t3lib_db.php (Arbeitskopie)
720 720
		return $wgolParts;
721 721
	}
722 722

  
723
	/**
724
	 * Tries to obtain a lock with a name given by the string $name with an optional timeout in seconds.
725
	 *
726
	 * Return values:
727
	 * - 1: the lock was obtained successfully
728
	 * - 0: the attempt timed out (because lock existed before and was not released withing the timeout)
729
	 * - null: an error occurred
730
	 *
731
	 * @param	string		$name: Name identifying the lock
732
	 * @param	integer		$timeout: Timeout for the attempt to obtain a lock
733
	 * @return	mixed		Returns 1 if the lock was obtained or 0/null if not (see method comment for more details)
734
	 */
735
	public function getLock($name, $timeout=0) {
736
		$timeout = intval($timeout);
737
		$resource = $this->sql_query('SELECT GET_LOCK('.$this->fullQuoteStr($name, '_DEFAULT').($timeout>0 ? ', '.$timeout : '').')');
738
		if (is_resource($resource)) {
739
			list($result) = $this->sql_fetch_row($resource);
740
			$this->sql_free_result($resource);
741
		}
742
		return $result;
743
	}
723 744

  
745
	/**
746
	 * Releases the lock named by the string $name that was obtained with getLock().
747
	 *
748
	 * Return values:
749
	 * - 1: the lock was released
750
	 * - 0: the lock was not established by this thread and thus cannot be released
751
	 * - null: the named lock did not exist
752
	 *
753
	 * @param	string		$name: Name identifying the lock
754
	 * @return	mixed		Returns 1 if the lock was released or 0/null if not (see method comment for more details)
755
	 */
756
	public function releaseLock($name) {
757
		$resource = $this->sql_query('SELECT RELEASE_LOCK('.$this->fullQuoteStr($name, '_DEFAULT').')');
758
		if (is_resource($resource)) {
759
			list($result) = $this->sql_fetch_row($resource);
760
			$this->sql_free_result($resource);
761
		}
762
		return $result;
763
	}
724 764

  
765
	/**
766
	 * Checkes whether the lock named by the string $name is free to use and thus not locked.
767
	 *
768
	 * Return values:
769
	 * - 1: the lock is free
770
	 * - 0: the lock is in use
771
	 * - null: an error occurred
772
	 *
773
	 * @param	string		$name: Name identifying the lock
774
	 * @return	mixed		Returns 1 if the lock is free or 0/null if not (see method comment for more details)
775
	 */
776
	public function isFreeLock($name) {
777
		$resource = $this->sql_query('SELECT IS_FREE_LOCK('.$this->fullQuoteStr($name, '_DEFAULT').')');
778
		if (is_resource($resource)) {
779
			list($result) = $this->sql_fetch_row($resource);
780
			$this->sql_free_result($resource);
781
		}
782
		return $result;
783
	}
725 784

  
726 785

  
727 786

  
......
734 793

  
735 794

  
736 795

  
796

  
797

  
798

  
737 799
	/**************************************
738 800
	 *
739 801
	 * MySQL wrapper functions
t3lib/class.t3lib_lock.php (Arbeitskopie)
119 119
					$success = true;
120 120
				}
121 121
			break;
122
			case 'database':
123
				$this->resource = $this->id = md5($id);
124
				$success = true;
125
			break;
122 126
			case 'disable':
123 127
				return false;
124 128
			break;
......
190 194
					$noWait = false;
191 195
				}
192 196
			break;
197
			case 'database':
198
				$result = $GLOBALS['TYPO3_DB']->getLock($this->resource, $this->loops*$this->step);
199
				if (!$result) {
200
					if (isset($result)) {
201
						$this->sysLog('Trying to acquire the lock timed out');
202
					} else {
203
						$this->sysLog('An error occurred while trying to acquire the lock', 3);
204
					}
205
					$noWait = false;
206
					$isAcquired = false;
207
				}
208
			break;
193 209
			case 'disable':
194 210
				$noWait = false;
195 211
				$isAcquired = false;
......
231 247
					$success = false;
232 248
				}
233 249
			break;
250
			case 'database':
251
				$result = $GLOBALS['TYPO3_DB']->releaseLock($this->resource);
252
				if (!$result) {
253
					if (isset($result)) {
254
						$this->sysLog('Could not release a lock which is owned by another process');
255
						$success = false;
256
					} else {
257
						$this->sysLog('The lock to be released did not exist (anymore)');
258
					}
259
				}
260
			break;
234 261
			case 'disable':
235 262
				$success = false;
236 263
			break;
typo3/sysext/cms/tslib/class.tslib_fe.php (Arbeitskopie)
2817 2817
	 */
2818 2818
	function releasePageGenerationLock(&$lockObj) {
2819 2819
		$success = false;
2820
			// If lock object is set and was aquired (may also happen if no_cache was enabled during runtime), release it:
2820
			// If lock object is set and was acquired (may also happen if no_cache was enabled during runtime), release it:
2821 2821
		if (is_object($lockObj) && $lockObj instanceof t3lib_lock && $lockObj->getLockStatus()) {
2822 2822
			$success = $lockObj->release();
2823 2823
			$lockObj->sysLog('Released lock');