From: Aaron Schulz Date: Wed, 7 Feb 2018 00:47:00 +0000 (-0800) Subject: rdbms: apply minimum sanity timeout for all cases of LoadBalancer::doWait() X-Git-Tag: 1.31.0-rc.0~666^2 X-Git-Url: https://git.heureux-cyclage.org/?p=lhc%2Fweb%2Fwiklou.git;a=commitdiff_plain;h=734aafcfbd49c2da176dd5f9d99cebc202f90bd6 rdbms: apply minimum sanity timeout for all cases of LoadBalancer::doWait() Change-Id: I61b4da6429b390e5aae65d1a30adc6df59687d8c --- diff --git a/includes/libs/rdbms/loadbalancer/LoadBalancer.php b/includes/libs/rdbms/loadbalancer/LoadBalancer.php index 4ce7c6c5a7..f41088251a 100644 --- a/includes/libs/rdbms/loadbalancer/LoadBalancer.php +++ b/includes/libs/rdbms/loadbalancer/LoadBalancer.php @@ -526,7 +526,7 @@ class LoadBalancer implements ILoadBalancer { for ( $i = 1; $i < $serverCount; $i++ ) { if ( $this->mLoads[$i] > 0 ) { $start = microtime( true ); - $ok = $this->doWait( $i, true, max( 1, (int)$timeout ) ) && $ok; + $ok = $this->doWait( $i, true, $timeout ) && $ok; $timeout -= ( microtime( true ) - $start ); if ( $timeout <= 0 ) { break; // timeout reached @@ -579,7 +579,7 @@ class LoadBalancer implements ILoadBalancer { * @return bool */ protected function doWait( $index, $open = false, $timeout = null ) { - $close = false; // close the connection afterwards + $timeout = max( 1, $timeout ?: $this->mWaitTimeout ); // Check if we already know that the DB has reached this point $server = $this->getServerName( $index ); @@ -599,6 +599,7 @@ class LoadBalancer implements ILoadBalancer { } // Find a connection to wait on, creating one if needed and allowed + $close = false; // close the connection afterwards $conn = $this->getAnyOpenConnection( $index ); if ( !$conn ) { if ( !$open ) { @@ -630,7 +631,6 @@ class LoadBalancer implements ILoadBalancer { [ 'dbserver' => $server ] ); - $timeout = $timeout ?: $this->mWaitTimeout; $result = $conn->masterPosWait( $this->mWaitForPos, $timeout ); if ( $result === null ) {