* If new connections are created, they will be closed before
making the next ones now.
Change-Id: I289d81ec00d3e1e313624e2a4c28a67bfb317feb
* @return bool
*/
protected function doWait( $index, $open = false, $timeout = null ) {
* @return bool
*/
protected function doWait( $index, $open = false, $timeout = null ) {
- # Find a connection to wait on
+ $close = false; // close the connection afterwards
+
+ # Find a connection to wait on, creating one if needed and allowed
$conn = $this->getAnyOpenConnection( $index );
if ( !$conn ) {
if ( !$open ) {
$conn = $this->getAnyOpenConnection( $index );
if ( !$conn ) {
if ( !$open ) {
+ // Avoid connection spam in waitForAll() when connections
+ // are made just for the sake of doing this lag check.
+ $close = true;
if ( $result == -1 || is_null( $result ) ) {
# Timed out waiting for slave, use master instead
wfDebug( __METHOD__ . ": Timed out waiting for slave #$index pos {$this->mWaitForPos}\n" );
if ( $result == -1 || is_null( $result ) ) {
# Timed out waiting for slave, use master instead
wfDebug( __METHOD__ . ": Timed out waiting for slave #$index pos {$this->mWaitForPos}\n" );
} else {
wfDebug( __METHOD__ . ": Done\n" );
} else {
wfDebug( __METHOD__ . ": Done\n" );
+ if ( $close ) {
+ $this->closeConnection( $conn );