Skip to content
Snippets Groups Projects
Commit cf8a9ece authored by Marco De Marco's avatar Marco De Marco
Browse files

Mysql server has gone away fix

parent a1fb492b
No related merge requests found
......@@ -58,6 +58,8 @@ void DBManager::connectAll() throw(soci::soci_error)
boost::mutex::scoped_lock lock(m_sessionMutex);
bool reconnect = true;
std::stringstream connection;
connection << " host=" << m_configuration_sp->getDatabaseHost();
......@@ -71,6 +73,14 @@ void DBManager::connectAll() throw(soci::soci_error)
m_mainSession_sp->open(soci::mysql, connection.str());
soci::mysql_session_backend* mainBackend =
static_cast<soci::mysql_session_backend*>(
m_mainSession_sp->get_backend());
MYSQL* mainMysql = mainBackend->conn_;
mysql_options(mainMysql, MYSQL_OPT_RECONNECT, &reconnect);
connection.str("");
connection << " host=" << m_configuration_sp->getAuxDatabaseHost();
......@@ -83,6 +93,14 @@ void DBManager::connectAll() throw(soci::soci_error)
#endif
m_auxSession_sp->open(soci::mysql, connection.str());
soci::mysql_session_backend* auxBackend =
static_cast<soci::mysql_session_backend*>(
m_auxSession_sp->get_backend());
MYSQL* auxMysql = auxBackend->conn_;
mysql_options(auxMysql, MYSQL_OPT_RECONNECT, &reconnect);
}
//==============================================================================
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment