summaryrefslogtreecommitdiffstats
path: root/lib/private
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2020-07-06 14:06:41 +0200
committerGitHub <noreply@github.com>2020-07-06 14:06:41 +0200
commite878c0a054ac86e1a8791306486a826d9231f35f (patch)
treedee0911d70fd0b113a4d1ed4cb17c09b1e18069d /lib/private
parentd72d9ff1f48eb282101c29aeea2a13c7f1368f8f (diff)
parent6886b46ee28addba626cc1e8a87181ca2800de25 (diff)
downloadnextcloud-server-e878c0a054ac86e1a8791306486a826d9231f35f.tar.gz
nextcloud-server-e878c0a054ac86e1a8791306486a826d9231f35f.zip
Merge pull request #21074 from jvsalo/shared-lock-multi-release
Fix releasing a shared lock multiple times
Diffstat (limited to 'lib/private')
-rw-r--r--lib/private/Lock/MemcacheLockingProvider.php6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/private/Lock/MemcacheLockingProvider.php b/lib/private/Lock/MemcacheLockingProvider.php
index c9dfcea3197..b8b4cef275d 100644
--- a/lib/private/Lock/MemcacheLockingProvider.php
+++ b/lib/private/Lock/MemcacheLockingProvider.php
@@ -95,8 +95,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);