Fixed destructor in FSLockManager to clear all the locks.
authorAaron Schulz <aschulz@wikimedia.org>
Sat, 2 Jun 2012 22:13:31 +0000 (15:13 -0700)
committerAaron Schulz <aschulz@wikimedia.org>
Sat, 2 Jun 2012 22:13:31 +0000 (15:13 -0700)
Change-Id: I019d24c19f317eb649b5a0415618b453e1ea171b

includes/filerepo/backend/lockmanager/FSLockManager.php

index 4f3b959..2b727a8 100644 (file)
@@ -239,11 +239,15 @@ class FSLockManager extends LockManager {
                return "{$this->lockDir}/{$hash}.lock";
        }
 
+       /**
+        * Make sure remaining locks get cleared for sanity
+        */
        function __destruct() {
-               // Make sure remaining locks get cleared for sanity
-               foreach ( $this->locksHeld as $path => $locks ) {
-                       $this->doSingleUnlock( $path, self::LOCK_EX );
-                       $this->doSingleUnlock( $path, self::LOCK_SH );
+               while ( count( $this->locksHeld ) ) {
+                       foreach ( $this->locksHeld as $path => $locks ) {
+                               $this->doSingleUnlock( $path, self::LOCK_EX );
+                               $this->doSingleUnlock( $path, self::LOCK_SH );
+                       }
                }
        }
 }