aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/server/authserver/Main.cpp13
-rwxr-xr-xsrc/server/shared/Database/DatabaseWorkerPool.h2
-rwxr-xr-xsrc/server/shared/Database/MySQLThreading.h14
-rwxr-xr-xsrc/server/worldserver/Master.cpp16
-rwxr-xr-xsrc/server/worldserver/Master.h1
5 files changed, 36 insertions, 10 deletions
diff --git a/src/server/authserver/Main.cpp b/src/server/authserver/Main.cpp
index b3add13e9f8..29b5e508102 100755
--- a/src/server/authserver/Main.cpp
+++ b/src/server/authserver/Main.cpp
@@ -38,6 +38,7 @@
#endif
bool StartDB();
+void StopDB();
bool stopEvent = false; // Setting it to true stops the server
@@ -235,8 +236,8 @@ extern int main(int argc, char **argv)
}
}
- // Close the Database Pool
- LoginDatabase.Close();
+ // Close the Database Pool and library
+ StopDB();
sLog->outString("Halting process...");
return 0;
@@ -245,6 +246,8 @@ extern int main(int argc, char **argv)
// Initialize connection to the database
bool StartDB()
{
+ MySQL::Library_Init();
+
std::string dbstring = sConfig->GetStringDefault("LoginDatabaseInfo", "");
if (dbstring.empty())
{
@@ -275,3 +278,9 @@ bool StartDB()
return true;
}
+
+void StopDB()
+{
+ LoginDatabase.Close();
+ MySQL::Library_End();
+} \ No newline at end of file
diff --git a/src/server/shared/Database/DatabaseWorkerPool.h b/src/server/shared/Database/DatabaseWorkerPool.h
index 6c1be4c5a42..27a5c051ccb 100755
--- a/src/server/shared/Database/DatabaseWorkerPool.h
+++ b/src/server/shared/Database/DatabaseWorkerPool.h
@@ -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)
diff --git a/src/server/shared/Database/MySQLThreading.h b/src/server/shared/Database/MySQLThreading.h
index 40b524a2c44..33f24d9aba5 100755
--- a/src/server/shared/Database/MySQLThreading.h
+++ b/src/server/shared/Database/MySQLThreading.h
@@ -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 \ No newline at end of file
diff --git a/src/server/worldserver/Master.cpp b/src/server/worldserver/Master.cpp
index 451aa3c175d..7dd4c1fa930 100755
--- a/src/server/worldserver/Master.cpp
+++ b/src/server/worldserver/Master.cpp
@@ -300,10 +300,7 @@ int Master::Run()
///- Clean database before leaving
clearOnlineAccounts();
- ///- Wait for delay threads to end
- CharacterDatabase.Close();
- WorldDatabase.Close();
- LoginDatabase.Close();
+ _StopDB();
sLog->outString("Halting process...");
@@ -368,6 +365,8 @@ int Master::Run()
/// Initialize connection to the databases
bool Master::_StartDB()
{
+ MySQL::Library_Init();
+
sLog->SetLogDB(false);
std::string dbstring;
uint8 async_threads, synch_threads;
@@ -471,6 +470,15 @@ bool Master::_StartDB()
return true;
}
+void Master::_StopDB()
+{
+ CharacterDatabase.Close();
+ WorldDatabase.Close();
+ LoginDatabase.Close();
+
+ MySQL::Library_End();
+}
+
/// Clear 'online' status for all accounts with characters in this realm
void Master::clearOnlineAccounts()
{
diff --git a/src/server/worldserver/Master.h b/src/server/worldserver/Master.h
index 8d2b77ad8cd..76259199d68 100755
--- a/src/server/worldserver/Master.h
+++ b/src/server/worldserver/Master.h
@@ -35,6 +35,7 @@ class Master
private:
bool _StartDB();
+ void _StopDB();
void clearOnlineAccounts();
};