2 namespace TYPO3\CMS\Core\Locking;
17 use TYPO3\CMS\Core\Locking\Exception\LockAcquireException;
18 use TYPO3\CMS\Core\Locking\Exception\LockCreateException;
54 $path = PATH_site . self::FILE_LOCK_FOLDER;
63 if (!is_writable($path)) {
66 $this->filePath = $path .
'sem_' . md5((
string)$subject);
67 touch($this->filePath);
68 $this->
id = ftok($this->filePath,
'A');
69 if ($this->
id ===
false) {
70 throw new LockCreateException(
'Cannot create key for semaphore using path ' . $this->filePath, 1396278734);
98 return (
bool)@sem_release($this->resource);
116 if (function_exists(
'sem_get')) {
117 return self::LOCK_CAPABILITY_EXCLUSIVE;
129 public function acquire($mode = self::LOCK_CAPABILITY_EXCLUSIVE)
135 $this->resource = sem_get($this->
id, 1);
136 if ($this->resource ===
false) {
140 $this->
isAcquired = (bool)sem_acquire($this->resource);
159 if ($this->resource) {
160 sem_remove($this->resource);
161 @unlink($this->filePath);