[8328] Fixed problem with crash at startup in result destroy anti-freeze thread runnable.

* Destroy runnable only if no references.
* Some code cleanups
This commit is contained in:
VladimirMangos 2009-08-08 09:35:59 +04:00
parent 79c1324bed
commit 7baebcd2de
5 changed files with 50 additions and 18 deletions

View file

@ -223,8 +223,8 @@ int Master::Run()
_HookSignals();
///- Launch WorldRunnable thread
ACE_Based::Thread t(new WorldRunnable);
t.setPriority(ACE_Based::Highest);
ACE_Based::Thread world_thread(new WorldRunnable);
world_thread.setPriority(ACE_Based::Highest);
// set server online
loginDatabase.PExecute("UPDATE realmlist SET color = 0, population = 0 WHERE id = '%d'",realmID);
@ -241,7 +241,7 @@ int Master::Run()
cliThread = new ACE_Based::Thread(new CliRunnable);
}
ACE_Based::Thread td2(new RARunnable);
ACE_Based::Thread rar_thread(new RARunnable);
///- Handle affinity for multiple processors and process priority on Windows
#ifdef WIN32
@ -297,13 +297,12 @@ int Master::Run()
uint32 loopCounter = 0;
///- Start up freeze catcher thread
uint32 freeze_delay = sConfig.GetIntDefault("MaxCoreStuckTime", 0);
if(freeze_delay)
if(uint32 freeze_delay = sConfig.GetIntDefault("MaxCoreStuckTime", 0))
{
FreezeDetectorRunnable *fdr = new FreezeDetectorRunnable();
fdr->SetDelayTime(freeze_delay*1000);
ACE_Based::Thread t(fdr);
t.setPriority(ACE_Based::Highest);
ACE_Based::Thread freeze_thread(fdr);
freeze_thread.setPriority(ACE_Based::Highest);
}
///- Launch the world listener socket
@ -327,8 +326,8 @@ int Master::Run()
// when the main thread closes the singletons get unloaded
// since worldrunnable uses them, it will crash if unloaded after master
t.wait();
td2.wait ();
world_thread.wait();
rar_thread.wait ();
///- Clean database before leaving
clearOnlineAccounts();
@ -340,7 +339,7 @@ int Master::Run()
sLog.outString( "Halting process..." );
if(cliThread)
if (cliThread)
{
#ifdef WIN32