Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2018-07-05 15:39:10 +0300
committerRobin Appelman <robin@icewind.nl>2018-07-05 15:39:10 +0300
commit3d5acbb1d0944ba00fee9af72f7253e6fc7f787e (patch)
tree48ae7acd74515bd11884d02edc9f241425866d44 /tests/lib/Lock
parent42912a0e2500f4ce0ff2f9921539283d4239e8a9 (diff)
prevent lock values from going negative with memcache backend
This can be caused by the code releasing more locks then it acquires, once the lock value becomes negative it's likely that it will never be able to change into an exclusive lock again. Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'tests/lib/Lock')
-rw-r--r--tests/lib/Lock/LockingProvider.php12
1 files changed, 12 insertions, 0 deletions
diff --git a/tests/lib/Lock/LockingProvider.php b/tests/lib/Lock/LockingProvider.php
index 49742baa561..9c0461e2e60 100644
--- a/tests/lib/Lock/LockingProvider.php
+++ b/tests/lib/Lock/LockingProvider.php
@@ -243,4 +243,16 @@ abstract class LockingProvider extends TestCase {
$this->instance->acquireLock('foo', ILockingProvider::LOCK_SHARED);
$this->instance->changeLock('foo', ILockingProvider::LOCK_SHARED);
}
+
+ public function testReleaseNonExistingShared() {
+ $this->instance->acquireLock('foo', ILockingProvider::LOCK_SHARED);
+ $this->instance->releaseLock('foo', ILockingProvider::LOCK_SHARED);
+
+ // releasing a lock once to many should not result in a locked state
+ $this->instance->releaseLock('foo', ILockingProvider::LOCK_SHARED);
+
+ $this->instance->acquireLock('foo', ILockingProvider::LOCK_EXCLUSIVE);
+ $this->assertTrue($this->instance->isLocked('foo', ILockingProvider::LOCK_EXCLUSIVE));
+ $this->instance->releaseLock('foo', ILockingProvider::LOCK_EXCLUSIVE);
+ }
}