X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FLock%2FAbstractLockDriver.php;h=0aedeeb1b09ab61cdf71c144c7df3b6cd02e6263;hb=c713c2bf622257dbecf223b5f58bf8a98dde9d65;hp=4c2bfaec9545ffe25715c3a7d635e1b633f57e57;hpb=4b7be15560e3e9623d806a86bd999a513e281d4f;p=friendica.git diff --git a/src/Core/Lock/AbstractLockDriver.php b/src/Core/Lock/AbstractLockDriver.php index 4c2bfaec95..0aedeeb1b0 100644 --- a/src/Core/Lock/AbstractLockDriver.php +++ b/src/Core/Lock/AbstractLockDriver.php @@ -1,15 +1,16 @@ acquireLock[$key]); + protected function hasAcquiredLock($key) + { + return isset($this->acquireLock[$key]) && $this->acquiredLocks[$key] === true; } /** - * @brief Mark a locally acquired lock + * Mark a locally acquired lock * * @param string $key The Name of the lock */ - protected function markAcquire(string $key) { + protected function markAcquire($key) + { $this->acquiredLocks[$key] = true; } /** - * @brief Mark a release of a locally acquired lock + * Mark a release of a locally acquired lock * * @param string $key The Name of the lock */ - protected function markRelease(string $key) { + protected function markRelease($key) + { unset($this->acquiredLocks[$key]); } /** - * @brief Releases all lock that were set by us + * Releases all lock that were set by us * - * @return void + * @return boolean Was the unlock of all locks successful? */ - public function releaseAll() { - foreach ($this->acquiredLocks as $acquiredLock) { - $this->releaseLock($acquiredLock); + public function releaseAll() + { + $return = true; + + foreach ($this->acquiredLocks as $acquiredLock => $hasLock) { + if (!$this->releaseLock($acquiredLock)) { + $return = false; + } } + + return $return; } }