(bug 13140) Show parent categories in category namespace
[lhc/web/wiklou.git] / includes / LoadBalancer.php
index 6efcbdd..0cdadd1 100644 (file)
@@ -16,12 +16,6 @@ class LoadBalancer {
        /* private */ var $mWaitForFile, $mWaitForPos, $mWaitTimeout;
        /* private */ var $mLaggedSlaveMode, $mLastError = 'Unknown error';
 
-       /**
-        * Scale polling time so that under overload conditions, the database server
-        * receives a SHOW STATUS query at an average interval of this many microseconds
-        */
-       const AVG_STATUS_POLL = 2000;
-
        function __construct( $servers, $failFunction = false, $waitTimeout = 10, $waitForMasterNow = false )
        {
                $this->mServers = $servers;
@@ -133,7 +127,7 @@ class LoadBalancer {
         * Side effect: opens connections to databases
         */
        function getReaderIndex() {
-               global $wgReadOnly, $wgDBClusterTimeout;
+               global $wgReadOnly, $wgDBClusterTimeout, $wgDBAvgStatusPoll;
 
                $fname = 'LoadBalancer::getReaderIndex';
                wfProfileIn( $fname );
@@ -180,7 +174,7 @@ class LoadBalancer {
                                                                # Too much load, back off and wait for a while.
                                                                # The sleep time is scaled by the number of threads connected,
                                                                # to produce a roughly constant global poll rate.
-                                                               $sleepTime = self::AVG_STATUS_POLL * $status['Threads_connected'];
+                                                               $sleepTime = $wgDBAvgStatusPoll * $status['Threads_connected'];
 
                                                                # If we reach the timeout and exit the loop, don't use it
                                                                $i = false;
@@ -432,8 +426,7 @@ class LoadBalancer {
                return $db;
        }
 
-       function reportConnectionError( &$conn )
-       {
+       function reportConnectionError( &$conn ) {
                $fname = 'LoadBalancer::reportConnectionError';
                wfProfileIn( $fname );
                # Prevent infinite recursion
@@ -556,9 +549,9 @@ class LoadBalancer {
        /* Issue COMMIT only on master, only if queries were done on connection */
        function commitMasterChanges() {
                // Always 0, but who knows.. :)
-               $i = $this->getWriterIndex;
+               $i = $this->getWriterIndex();
                if (array_key_exists($i,$this->mConnections)) {
-                       if ($this->mConnections[$i]->lastQuery != '') {
+                       if ($this->mConnections[$i]->lastQuery() != '') {
                                $this->mConnections[$i]->immediateCommit();
                        }
                }