aboutsummaryrefslogtreecommitdiff
path: root/src/server/shared/Database/MySQLConnection.cpp
diff options
context:
space:
mode:
authorRat <gmstreetrat@gmail.com>2015-03-29 17:56:49 +0200
committerRat <gmstreetrat@gmail.com>2015-03-29 17:56:49 +0200
commitdcd18eef2a8bb3c8eeb5552d76f2af4ad6dc7bfa (patch)
tree594ac771e6813bc0b9a7f56d2b5f0de3ebdf36f6 /src/server/shared/Database/MySQLConnection.cpp
parent81df6b2ad23d4f405ef088c5405bd079e6570a9d (diff)
parent833d57fa27c782c2e9a211ec19c554d057431243 (diff)
Merge branch '6.x' of https://github.com/TrinityCore/TrinityCore into 6.x
Diffstat (limited to 'src/server/shared/Database/MySQLConnection.cpp')
-rw-r--r--src/server/shared/Database/MySQLConnection.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/server/shared/Database/MySQLConnection.cpp b/src/server/shared/Database/MySQLConnection.cpp
index 5a98757abb5..a16559a55dc 100644
--- a/src/server/shared/Database/MySQLConnection.cpp
+++ b/src/server/shared/Database/MySQLConnection.cpp
@@ -79,7 +79,7 @@ uint32 MySQLConnection::Open()
if (!mysqlInit)
{
TC_LOG_ERROR("sql.sql", "Could not initialize Mysql connection to database `%s`", m_connectionInfo.database.c_str());
- return false;
+ return CR_UNKNOWN_ERROR;
}
int port;
@@ -492,9 +492,17 @@ bool MySQLConnection::_HandleMySQLErrno(uint32 errNo)
uint64 oldThreadId = mysql_thread_id(GetHandle());
mysql_close(GetHandle());
- // Don't remove 'this' pointer unless you want to skip loading all prepared statements....
- if (this->Open() && this->PrepareStatements())
+ uint32 const lErrno = Open();
+ if (!lErrno)
{
+ // Don't remove 'this' pointer unless you want to skip loading all prepared statements...
+ if (!this->PrepareStatements())
+ {
+ TC_LOG_ERROR("sql.sql", "Could not re-prepare statements!");
+ Close();
+ return false;
+ }
+
TC_LOG_INFO("sql.sql", "Connection to the MySQL server is active.");
if (oldThreadId != mysql_thread_id(GetHandle()))
TC_LOG_INFO("sql.sql", "Successfully reconnected to %s @%s:%s (%s).",
@@ -505,7 +513,7 @@ bool MySQLConnection::_HandleMySQLErrno(uint32 errNo)
return true;
}
- uint32 lErrno = mysql_errno(GetHandle()); // It's possible this attempted reconnect throws 2006 at us. To prevent crazy recursive calls, sleep here.
+ // It's possible this attempted reconnect throws 2006 at us. To prevent crazy recursive calls, sleep here.
std::this_thread::sleep_for(std::chrono::seconds(3)); // Sleep 3 seconds
return _HandleMySQLErrno(lErrno); // Call self (recursive)
}