diff options
author | Robin Appelman <icewind@owncloud.com> | 2016-04-29 12:54:33 +0200 |
---|---|---|
committer | Robin Appelman <icewind@owncloud.com> | 2016-04-29 12:54:33 +0200 |
commit | 49ad0fcfa9eba188d5032f8ffcd95d7cc235db80 (patch) | |
tree | 85fa60741fde62a3630ad202421a1fafd6096cce /lib/private/Lock/MemcacheLockingProvider.php | |
parent | 5b45f0f91448f109ff33d4fb03368a0405e1da10 (diff) | |
download | nextcloud-server-49ad0fcfa9eba188d5032f8ffcd95d7cc235db80.tar.gz nextcloud-server-49ad0fcfa9eba188d5032f8ffcd95d7cc235db80.zip |
optimize releaselock for memcache based locking backends
Diffstat (limited to 'lib/private/Lock/MemcacheLockingProvider.php')
-rw-r--r-- | lib/private/Lock/MemcacheLockingProvider.php | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/private/Lock/MemcacheLockingProvider.php b/lib/private/Lock/MemcacheLockingProvider.php index 536b29e2c28..56e581b2192 100644 --- a/lib/private/Lock/MemcacheLockingProvider.php +++ b/lib/private/Lock/MemcacheLockingProvider.php @@ -88,9 +88,14 @@ class MemcacheLockingProvider extends AbstractLockingProvider { */ public function releaseLock($path, $type) { if ($type === self::LOCK_SHARED) { - if (isset($this->acquiredLocks['shared'][$path]) and $this->acquiredLocks['shared'][$path] > 0) { + if ($this->getOwnSharedLockCount($path) === 1) { + $removed = $this->memcache->cad($path, 1); // if we're the only one having a shared lock we can remove it in one go + if (!$removed) { //someone else also has a shared lock, decrease only + $this->memcache->dec($path); + } + } else { + // if we own more than one lock ourselves just decrease $this->memcache->dec($path); - $this->memcache->cad($path, 0); } } else if ($type === self::LOCK_EXCLUSIVE) { $this->memcache->cad($path, 'exclusive'); |