- back-end programs: set MySQL option to reconnect to server

if the connection goes away
    (which it apparently does if idle for a while)

svn path=/trunk/boinc/; revision=16532
This commit is contained in:
David Anderson 2008-11-19 00:16:07 +00:00
parent 6322fe2254
commit b5cece0928
2 changed files with 20 additions and 0 deletions

View File

@ -9496,3 +9496,11 @@ David 18 Nov 2008
gui_rpc_server.cpp
html/ops/
update_profile_pages.php
David 18 Nov 2008
- back-end programs: set MySQL option to reconnect to server
if the connection goes away
(which it apparently does if idle for a while)
db/
db_base.cpp

View File

@ -41,8 +41,20 @@ DB_CONN::DB_CONN() {
int DB_CONN::open(char* db_name, char* db_host, char* db_user, char* dbpassword) {
mysql = mysql_init(0);
if (!mysql) return ERR_DB_CANT_INIT;
#if MYSQL_VERSION_ID >= 50106
my_bool mbReconnect = 1;
mysql_options(mysql, MYSQL_OPT_RECONNECT, &mbReconnect);
#endif
mysql = mysql_real_connect(mysql, db_host, db_user, dbpassword, db_name, 0, 0, 0);
if (mysql == 0) return ERR_DB_CANT_CONNECT;
// older versions of MySQL lib need to set the option AFTER connecting;
// see http://dev.mysql.com/doc/refman/5.1/en/mysql-options.html
//
#if MYSQL_VERSION_ID >= 50013 && MYSQL_VERSION_ID < 50106
my_bool mbReconnect = 1;
mysql_options(mysql, MYSQL_OPT_RECONNECT, &mbReconnect);
#endif
return 0;
}