dont release shared lock if we dont have any

This commit is contained in:
Robin Appelman 2015-05-20 16:25:41 +02:00
parent f0b8672729
commit 006eaa84aa
1 changed files with 4 additions and 2 deletions

View File

@ -88,8 +88,10 @@ class MemcacheLockingProvider implements ILockingProvider {
*/ */
public function releaseLock($path, $type) { public function releaseLock($path, $type) {
if ($type === self::LOCK_SHARED) { if ($type === self::LOCK_SHARED) {
if (isset($this->acquiredLocks['shared'][$path]) and $this->acquiredLocks['shared'][$path] > 0) {
$this->memcache->dec($path); $this->memcache->dec($path);
$this->acquiredLocks['shared'][$path]--; $this->acquiredLocks['shared'][$path]--;
}
} else if ($type === self::LOCK_EXCLUSIVE) { } else if ($type === self::LOCK_EXCLUSIVE) {
$this->memcache->cas($path, 'exclusive', 0); $this->memcache->cas($path, 'exclusive', 0);
unset($this->acquiredLocks['exclusive'][$path]); unset($this->acquiredLocks['exclusive'][$path]);