Core/DBLayer: Properly manage mysql library initialization and shutdown in authserver and worldserver. Prevent multiple calls and make it more elegant.

This commit is contained in:
Machiavelli
2011-01-13 21:30:37 +01:00
parent 4c15ebe09d
commit bd85914d92
5 changed files with 36 additions and 10 deletions
@@ -58,14 +58,12 @@ class DatabaseWorkerPool
memset(m_connectionCount, 0, sizeof(m_connectionCount));
m_connections.resize(IDX_SIZE);
mysql_library_init(-1, NULL, NULL);
WPFatal (mysql_thread_safe(), "Used MySQL library isn't thread-safe.");
}
~DatabaseWorkerPool()
{
sLog->outSQLDriver("~DatabaseWorkerPool for '%s'.", m_connectionInfo.database.c_str());
mysql_library_end();
}
bool Open(const std::string& infoString, uint8 async_threads, uint8 synch_threads)
+12 -2
View File
@@ -33,7 +33,7 @@ class MySQL
static void Thread_Init()
{
mysql_thread_init();
printf("Core thread with ID ["UI64FMTD"] initializing MySQL thread.\n",
sLog->outSQLDriver("Core thread with ID ["UI64FMTD"] initializing MySQL thread.",
(uint64)ACE_Based::Thread::currentId());
}
@@ -44,9 +44,19 @@ class MySQL
static void Thread_End()
{
mysql_thread_end();
printf("Core thread with ID ["UI64FMTD"] shutting down MySQL thread.\n",
sLog->outSQLDriver("Core thread with ID ["UI64FMTD"] shutting down MySQL thread.",
(uint64)ACE_Based::Thread::currentId());
}
static void Library_Init()
{
mysql_library_init(-1, NULL, NULL);
}
static void Library_End()
{
mysql_library_end();
}
};
#endif