From: Aaron Schulz Date: Fri, 28 Jun 2019 23:56:16 +0000 (-0700) Subject: lockmanager: make NullLockManager do reference counting for consistency X-Git-Tag: 1.34.0-rc.0~1192^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22messagerie%22%29%20.%20%22?a=commitdiff_plain;h=b18dd6ebb0b1b16aaa4004397be44c82df3aa8d0;p=lhc%2Fweb%2Fwiklou.git lockmanager: make NullLockManager do reference counting for consistency Change-Id: I9ebdad0544ffcf87e671f4aca81a91e377c2c7ed --- diff --git a/includes/libs/lockmanager/NullLockManager.php b/includes/libs/lockmanager/NullLockManager.php index b83462c798..339a7ee43a 100644 --- a/includes/libs/lockmanager/NullLockManager.php +++ b/includes/libs/lockmanager/NullLockManager.php @@ -22,15 +22,38 @@ */ /** - * Simple version of LockManager that does nothing + * Simple version of LockManager that only does lock reference counting * @since 1.19 */ class NullLockManager extends LockManager { protected function doLock( array $paths, $type ) { + foreach ( $paths as $path ) { + if ( isset( $this->locksHeld[$path][$type] ) ) { + ++$this->locksHeld[$path][$type]; + } else { + $this->locksHeld[$path][$type] = 1; + } + } + return StatusValue::newGood(); } protected function doUnlock( array $paths, $type ) { - return StatusValue::newGood(); + $status = StatusValue::newGood(); + + foreach ( $paths as $path ) { + if ( isset( $this->locksHeld[$path][$type] ) ) { + if ( --$this->locksHeld[$path][$type] <= 0 ) { + unset( $this->locksHeld[$path][$type] ); + if ( !$this->locksHeld[$path] ) { + unset( $this->locksHeld[$path] ); // clean up + } + } + } else { + $status->warning( 'lockmanager-notlocked', $path ); + } + } + + return $status; } }