/**
  * Close a connection
  * Using this function makes sure the LoadBalancer knows the connection is closed.
  * If you use $conn->close() directly, the load balancer won't update its state.
  * @param DatabaseBase $conn
  */
 public function closeConnection($conn)
 {
     $done = false;
     foreach ($this->mConns as $i1 => $conns2) {
         foreach ($conns2 as $i2 => $conns3) {
             foreach ($conns3 as $i3 => $candidateConn) {
                 if ($conn === $candidateConn) {
                     $conn->close();
                     unset($this->mConns[$i1][$i2][$i3]);
                     --$this->connsOpened;
                     $done = true;
                     break;
                 }
             }
         }
     }
     if (!$done) {
         $conn->close();
     }
 }