Skip to content

Commit

Permalink
BoincDb::get():
Browse files Browse the repository at this point in the history
if open to different dbnum, close and reconnect.
Don't throw exception if connect fails
  • Loading branch information
davidpanderson committed Aug 17, 2024
1 parent 4b4ba9d commit da1727c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
5 changes: 4 additions & 1 deletion html/inc/boinc_db.inc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ class BoincDb {
static function get($dbnum = 0) {
global $generating_xml;
if (isset(self::$instance)) {
return self::$instance;
if (self::$dbnum == $dbnum) {
return self::$instance;
}
close();
}
if (web_stopped()) {
if ($generating_xml) {
Expand Down
12 changes: 4 additions & 8 deletions html/inc/db_conn.inc
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,10 @@ class DbConn {
} else {
$port = null;
}
if (1) { // don't use persistent connections for now
$this->db_conn = @new mysqli(
$host, $user, $passwd, $name, $port
);
} else {
$this->db_conn = @new mysqli(
'p:'.$host, $user, $passwd, $name, $port
);
try {
$this->db_conn = @new mysqli($host, $user, $passwd, $name, $port);
} catch(Exception $e) {
return false;
}
if (mysqli_connect_error()) {
return false;
Expand Down

0 comments on commit da1727c

Please sign in to comment.