summaryrefslogtreecommitdiff
path: root/includes/LoadBalancer.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/LoadBalancer.php')
-rw-r--r--includes/LoadBalancer.php13
1 files changed, 6 insertions, 7 deletions
diff --git a/includes/LoadBalancer.php b/includes/LoadBalancer.php
index 396ef865..4ebe26c7 100644
--- a/includes/LoadBalancer.php
+++ b/includes/LoadBalancer.php
@@ -1,7 +1,6 @@
<?php
/**
*
- * @package MediaWiki
*/
@@ -9,7 +8,6 @@
* Database load balancing object
*
* @todo document
- * @package MediaWiki
*/
class LoadBalancer {
/* private */ var $mServers, $mConnections, $mLoads, $mGroupLoads;
@@ -24,7 +22,7 @@ class LoadBalancer {
*/
const AVG_STATUS_POLL = 2000;
- function LoadBalancer( $servers, $failFunction = false, $waitTimeout = 10, $waitForMasterNow = false )
+ function __construct( $servers, $failFunction = false, $waitTimeout = 10, $waitForMasterNow = false )
{
$this->mServers = $servers;
$this->mFailFunction = $failFunction;
@@ -32,7 +30,7 @@ class LoadBalancer {
$this->mWriteIndex = -1;
$this->mForce = -1;
$this->mConnections = array();
- $this->mLastIndex = 1;
+ $this->mLastIndex = -1;
$this->mLoads = array();
$this->mWaitForFile = false;
$this->mWaitForPos = false;
@@ -97,7 +95,9 @@ class LoadBalancer {
# Unset excessively lagged servers
$lags = $this->getLagTimes();
foreach ( $lags as $i => $lag ) {
- if ( isset( $this->mServers[$i]['max lag'] ) && $lag > $this->mServers[$i]['max lag'] ) {
+ if ( $i != 0 && isset( $this->mServers[$i]['max lag'] ) &&
+ ( $lag === false || $lag > $this->mServers[$i]['max lag'] ) )
+ {
unset( $loads[$i] );
}
}
@@ -504,8 +504,7 @@ class LoadBalancer {
* Save master pos to the session and to memcached, if the session exists
*/
function saveMasterPos() {
- global $wgSessionStarted;
- if ( $wgSessionStarted && count( $this->mServers ) > 1 ) {
+ if ( session_id() != '' && count( $this->mServers ) > 1 ) {
# If this entire request was served from a slave without opening a connection to the
# master (however unlikely that may be), then we can fetch the position from the slave.
if ( empty( $this->mConnections[0] ) ) {