Skip to content

Commit

Permalink
- back-end programs: set MySQL option to reconnect to server
Browse files Browse the repository at this point in the history
    if the connection goes away
    (which it apparently does if idle for a while)

svn path=/trunk/boinc/; revision=16532
  • Loading branch information
davidpanderson committed Nov 19, 2008
1 parent 6322fe2 commit b5cece0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
8 changes: 8 additions & 0 deletions checkin_notes
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 12 additions & 0 deletions db/db_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit b5cece0

Please sign in to comment.