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: http://git.cyclocoop.org/data/%27%20.%20mediabox_timestamp%28find_in_path%28%27javascript/%7B%24www_url%7Dadmin/compta/operations/%40%20%27info_etape_suivante_2%27%20=%3E%20%27You%20can%20move%20on%20to%20the%20next%20step.%27%2C%20%27info_exceptions_proxy%27%20=%3E%20%27Exceptions%20for%20the%20proxy%27%2C%20%27info_exportation_base%27%20=%3E%20%27export%20database%20to%20%40archive%40%27%2C-%27info_facilite_suivi_activite%27%20=%3E%20%27To%20simplify%20monitoring%20of%20the%20site/%27s%20editorial;-%20%20activities%2C%20SPIP%20can%20send%20rmail%20notifications%2C%20e.g.%20to%20an%20editors/%27.%28%24current%20%3E%202?a=commitdiff_plain;h=734aafcfbd49c2da176dd5f9d99cebc202f90bd6;p=lhc%2Fweb%2Fwiklou.git 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 ) {