aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNaios <naios-dev@live.de>2015-03-29 14:25:10 +0200
committerNaios <naios-dev@live.de>2015-03-29 14:28:18 +0200
commit64868272043fa49f1de73a640efe1e3e3d31768b (patch)
tree69c25a2704d3659568fde48ad0afee436a219136
parent832234c47b90ad43b15451fcc0823822e2cebe57 (diff)
Core/Database: Fix a mistake in 54ee5267244acac16
* Also use proper errno instead of 0 when reconnecting. * Thanks @et65 for reporting * ref #14139 (cherry picked from commit 47410157b1d1e51062732696ad5f457a69019ef4)
-rw-r--r--src/server/shared/Database/MySQLConnection.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/server/shared/Database/MySQLConnection.cpp b/src/server/shared/Database/MySQLConnection.cpp
index 5a98757abb5..27de5ffc85e 100644
--- a/src/server/shared/Database/MySQLConnection.cpp
+++ b/src/server/shared/Database/MySQLConnection.cpp
@@ -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)
}