X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FCore%2FLock%2FAbstractLockDriver.php;h=0aedeeb1b09ab61cdf71c144c7df3b6cd02e6263;hb=c713c2bf622257dbecf223b5f58bf8a98dde9d65;hp=bcce26129c935d358ce511bc85e57c9878ee3814;hpb=b07dfbb03f06f72d8776da317361fa5bcad098e2;p=friendica.git diff --git a/src/Core/Lock/AbstractLockDriver.php b/src/Core/Lock/AbstractLockDriver.php index bcce26129c..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($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($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; } }