From cdf75379c9ce3c5d356d45e0c68ededb309fa6e9 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Mon, 18 Apr 2011 23:12:58 +0000 Subject: [PATCH] Apply LoadBalancer related fixes Patches by Yuvi Panda From (bug 28583) Remove all /* private */ declarations in MediaWiki core --- CREDITS | 1 + includes/db/LoadBalancer.php | 24 +++++++++++++++--------- maintenance/eval.php | 7 +++++-- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/CREDITS b/CREDITS index b9ef935082..9c8c010c7a 100644 --- a/CREDITS +++ b/CREDITS @@ -142,6 +142,7 @@ following names for their contribution to the product. * Tisane * Umherirrender * Ville Stadista +* Yuvaraj Pandian T * Zachary Hauri == Translators == diff --git a/includes/db/LoadBalancer.php b/includes/db/LoadBalancer.php index 46c6155546..42b4aa690a 100644 --- a/includes/db/LoadBalancer.php +++ b/includes/db/LoadBalancer.php @@ -13,13 +13,13 @@ * @ingroup Database */ class LoadBalancer { - /* private */ var $mServers, $mConns, $mLoads, $mGroupLoads; - /* private */ var $mErrorConnection; - /* private */ var $mReadIndex, $mAllowLagged; - /* private */ var $mWaitForPos, $mWaitTimeout; - /* private */ var $mLaggedSlaveMode, $mLastError = 'Unknown error'; - /* private */ var $mParentInfo, $mLagTimes; - /* private */ var $mLoadMonitorClass, $mLoadMonitor; + private $mServers, $mConns, $mLoads, $mGroupLoads; + private $mErrorConnection; + private $mReadIndex, $mAllowLagged; + private $mWaitForPos, $mWaitTimeout; + private $mLaggedSlaveMode, $mLastError = 'Unknown error'; + private $mParentInfo, $mLagTimes; + private $mLoadMonitorClass, $mLoadMonitor; /** * @param $params Array with keys: @@ -91,8 +91,7 @@ class LoadBalancer { * Given an array of non-normalised probabilities, this function will select * an element and return the appropriate key */ - function pickRandom( $weights ) - { + function pickRandom( $weights ) { if ( !is_array( $weights ) || count( $weights ) == 0 ) { return false; } @@ -739,6 +738,13 @@ class LoadBalancer { } } + /** + * Sets the server info structure for the given index. Entry at index $i is created if it doesn't exist + */ + function setServerInfo( $i, $serverInfo ) { + $this->mServers[i] = $serverInfo; + } + /** * Get the current master position for chronology control purposes * @return mixed diff --git a/maintenance/eval.php b/maintenance/eval.php index 74143b5dd4..33c9a5d72f 100644 --- a/maintenance/eval.php +++ b/maintenance/eval.php @@ -45,8 +45,11 @@ if ( isset( $options['d'] ) ) { } if ( $d > 1 ) { $lb = wfGetLB(); - foreach ( $lb->mServers as $i => $server ) { - $lb->mServers[$i]['flags'] |= DBO_DEBUG; + $serverCount = $lb->getServerCount(); + for ( $i = 0; $i < $serverCount; $i++ ) { + $server = $lb->getServerInfo( $i ); + $server['flags'] |= DBO_DEBUG; + $lb->setServerInfo( $i, $server ); } } if ( $d > 2 ) { -- 2.20.1