Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fix releasing a shared lock multiple times
Signed-off-by: Jaakko Salo <[email protected]>
  • Loading branch information
jvsalo authored and backportbot[bot] committed Jul 6, 2020
commit 392df2eaf4ae41530b4743305a765a7ec173e92a
6 changes: 5 additions & 1 deletion lib/private/Lock/MemcacheLockingProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,12 @@ public function acquireLock(string $path, int $type) {
*/
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);
Expand Down