From 005b50de926b34becb5b558bf53a210b06f031b3 Mon Sep 17 00:00:00 2001 From: HttrckCldHKS Date: Mon, 27 Oct 2014 17:55:23 -0700 Subject: [PATCH] Added MySQL Reconnect Feature If the connection times out or gets lost, this will prevent "MySQL server has gone away" error. --- dlls/mysqlx/mysql/MysqlDriver.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dlls/mysqlx/mysql/MysqlDriver.cpp b/dlls/mysqlx/mysql/MysqlDriver.cpp index 8e422fc0..89d5ed15 100644 --- a/dlls/mysqlx/mysql/MysqlDriver.cpp +++ b/dlls/mysqlx/mysql/MysqlDriver.cpp @@ -57,6 +57,12 @@ IDatabase *MysqlDriver::_Connect(DatabaseInfo *info, int *errcode, char *error, mysql_options(mysql, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&(info->max_timeout)); } + /** Have MySQL automatically reconnect if it times out or loses connection. + * This will prevent "MySQL server has gone away" errors after a while. + */ + my_bool my_true = true; + mysql_options(mysql, MYSQL_OPT_RECONNECT, (const char *)&my_true); + if (mysql_real_connect(mysql, info->host, info->user,