Merge "Clean up $wgSQLiteDataDir handling and removed standalone sqlite class"
[lhc/web/wiklou.git] / includes / db / LoadBalancer.php
index 917d703..4e0a5b9 100644 (file)
@@ -471,6 +471,9 @@ class LoadBalancer {
                        ? array( false ) // check one "group": the generic pool
                        : (array)$groups;
 
+               $masterOnly = ( $i == DB_MASTER || $i == $this->getWriterIndex() );
+               $oldConnsOpened = $this->connsOpened; // connections open now
+
                if ( $i == DB_MASTER ) {
                        $i = $this->getWriterIndex();
                } else {
@@ -506,6 +509,14 @@ class LoadBalancer {
                        return $this->reportConnectionError();
                }
 
+               # Profile any new connections that happen
+               if ( $this->connsOpened > $oldConnsOpened ) {
+                       $host = $conn->getServer();
+                       $dbname = $conn->getDBname();
+                       $trxProf = Profiler::instance()->getTransactionProfiler();
+                       $trxProf->recordConnection( $host, $dbname, $masterOnly );
+               }
+
                return $conn;
        }