diff options
author | Jaakko Salo <jaakkos@gmail.com> | 2020-05-24 03:19:04 +0300 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2020-07-06 12:11:46 +0000 |
commit | 392df2eaf4ae41530b4743305a765a7ec173e92a (patch) | |
tree | f58bd742e71e674fe01ebb3b4bd804bcee24c3a7 | |
parent | b6aac70529f2aff75a7195d61934b5a45dc22a5e (diff) | |
download | nextcloud-server-392df2eaf4ae41530b4743305a765a7ec173e92a.tar.gz nextcloud-server-392df2eaf4ae41530b4743305a765a7ec173e92a.zip |
Fix releasing a shared lock multiple times
Signed-off-by: Jaakko Salo <jaakkos@gmail.com>
-rw-r--r-- | lib/private/Lock/MemcacheLockingProvider.php | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/private/Lock/MemcacheLockingProvider.php b/lib/private/Lock/MemcacheLockingProvider.php index 3d7510f43ff..bff4eabbbd8 100644 --- a/lib/private/Lock/MemcacheLockingProvider.php +++ b/lib/private/Lock/MemcacheLockingProvider.php @@ -94,8 +94,12 @@ class MemcacheLockingProvider extends AbstractLockingProvider { */ public function releaseLock(string $path, int $type) { if ($type === self::LOCK_SHARED) { + $ownSharedLockCount = $this->getOwnSharedLockCount($path); $newValue = 0; - if ($this->getOwnSharedLockCount($path) === 1) { + if ($ownSharedLockCount === 0) { // if we are not holding the lock, don't try to release it + return; + } + if ($ownSharedLockCount === 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 $newValue = $this->memcache->dec($path); |