Merge pull request #3672 from BOINC/dpa_db_init

Server programs: try to print error message if can't connect to DB
This commit is contained in:
Vitalii Koshura 2020-05-07 10:39:17 +02:00 committed by GitHub
commit becc6e2c93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -85,10 +85,14 @@ int DB_CONN::open(
// CLIENT_FOUND_ROWS means that the # of affected rows for an update
// is the # matched by the where, rather than the # actually changed
//
mysql = mysql_real_connect(
MYSQL* mysql2 = mysql_real_connect(
mysql, host, db_user, dbpassword, db_name, port, 0, CLIENT_FOUND_ROWS
);
if (mysql == 0) return ERR_DB_CANT_CONNECT;
if (mysql2 == 0) {
fprintf(stderr, "mysql_real_connect(): %d: %s\n", mysql_errno(mysql), mysql_error(mysql));
return ERR_DB_CANT_CONNECT;
}
mysql = mysql2;
if (set_opt_after) {
bool mbReconnect = 1;