diff options
author | leak <leak@bitmx.net> | 2014-08-10 20:28:18 +0200 |
---|---|---|
committer | leak <leak@bitmx.net> | 2014-08-10 22:43:48 +0200 |
commit | 14cb6e4235ebb84ad41d6ceb4eaf56c0b55d9238 (patch) | |
tree | a4476afcf874ac1510130d01e02ada0725c50389 /src/server/worldserver/Main.cpp | |
parent | 9aea8046ce30515ea900c72b2a779c47bc6e7248 (diff) |
Resolve shutdown crash/leak if MySQL server is not running
Fixes #12734
Diffstat (limited to 'src/server/worldserver/Main.cpp')
-rw-r--r-- | src/server/worldserver/Main.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/server/worldserver/Main.cpp b/src/server/worldserver/Main.cpp index a879dca78b9..2c393215f7d 100644 --- a/src/server/worldserver/Main.cpp +++ b/src/server/worldserver/Main.cpp @@ -87,6 +87,7 @@ bool StartDB(); void StopDB(); void WorldUpdateLoop(); void ClearOnlineAccounts(); +void ShutdownThreadPool(std::vector<std::thread>& threadPool); variables_map GetConsoleArguments(int argc, char** argv, std::string& cfg_file, std::string& cfg_service); /// Launch the Trinity server @@ -179,7 +180,10 @@ extern int main(int argc, char** argv) // Start the databases if (!StartDB()) + { + ShutdownThreadPool(threadPool); return 1; + } // Set server offline (not connectable) LoginDatabase.DirectPExecute("UPDATE realmlist SET flag = (flag & ~%u) | %u WHERE id = '%d'", REALM_FLAG_OFFLINE, REALM_FLAG_INVALID, realmID); @@ -236,13 +240,7 @@ extern int main(int argc, char** argv) WorldUpdateLoop(); // Shutdown starts here - - _ioService.stop(); - - for (auto& thread : threadPool) - { - thread.join(); - } + ShutdownThreadPool(threadPool); sScriptMgr->OnShutdown(); @@ -296,6 +294,16 @@ extern int main(int argc, char** argv) return World::GetExitCode(); } +void ShutdownThreadPool(std::vector<std::thread>& threadPool) +{ + _ioService.stop(); + + for (auto& thread : threadPool) + { + thread.join(); + } +} + void WorldUpdateLoop() { uint32 realCurrTime = 0; |