Merge "Add autocomplete for WhatLinksHere subpages"
[lhc/web/wiklou.git] / includes / poolcounter / PoolCounterRedis.php
index 2b37b0b..98797a3 100644 (file)
@@ -90,7 +90,7 @@ class PoolCounterRedis extends PoolCounter {
 
                $this->keySha1 = sha1( $this->key );
                $met = ini_get( 'max_execution_time' ); // usually 0 in CLI mode
-               $this->lockTTL = $met ? 2*$met : 3600;
+               $this->lockTTL = $met ? 2 * $met : 3600;
 
                if ( self::$active === null ) {
                        self::$active = array();
@@ -121,19 +121,26 @@ class PoolCounterRedis extends PoolCounter {
        }
 
        function acquireForMe() {
-               $section = new ProfileSection( __METHOD__ );
+
+               $status = $this->precheckAcquire();
+               if ( !$status->isGood() ) {
+                       return $status;
+               }
 
                return $this->waitForSlotOrNotif( self::AWAKE_ONE );
        }
 
        function acquireForAnyone() {
-               $section = new ProfileSection( __METHOD__ );
+
+               $status = $this->precheckAcquire();
+               if ( !$status->isGood() ) {
+                       return $status;
+               }
 
                return $this->waitForSlotOrNotif( self::AWAKE_ALL );
        }
 
        function release() {
-               $section = new ProfileSection( __METHOD__ );
 
                if ( $this->slot === null ) {
                        return Status::newGood( PoolCounter::NOT_LOCKED ); // not locked
@@ -207,6 +214,8 @@ LUA;
                $this->onRelease = null;
                unset( self::$active[$this->session] );
 
+               $this->onRelease();
+
                return Status::newGood( PoolCounter::RELEASED );
        }
 
@@ -266,6 +275,8 @@ LUA;
                        self::$active[$this->session] = $this;
                }
 
+               $this->onAcquire();
+
                return Status::newGood( $slot === 'w' ? PoolCounter::DONE : PoolCounter::LOCKED );
        }