Fixed a deadlock
FS #363 git-svn-id: http://mc-server.googlecode.com/svn/trunk@1421 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
9794f8ddcb
commit
8418c7ba9a
@ -349,6 +349,18 @@ bool cRoot::ForEachWorld(cWorldListCallback & a_Callback)
|
|||||||
|
|
||||||
void cRoot::TickWorlds(float a_Dt)
|
void cRoot::TickWorlds(float a_Dt)
|
||||||
{
|
{
|
||||||
|
// Execute any pending commands:
|
||||||
|
AStringVector PendingCommands;
|
||||||
|
{
|
||||||
|
cCSLock Lock(m_CSPendingCommands);
|
||||||
|
std::swap(PendingCommands, m_PendingCommands);
|
||||||
|
}
|
||||||
|
for (AStringVector::iterator itr = PendingCommands.begin(), end = PendingCommands.end(); itr != end; ++itr)
|
||||||
|
{
|
||||||
|
DoExecuteConsoleCommand(*itr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tick the worlds:
|
||||||
for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr)
|
for (WorldMap::iterator itr = m_WorldsByName.begin(); itr != m_WorldsByName.end(); ++itr)
|
||||||
{
|
{
|
||||||
itr->second->Tick(a_Dt);
|
itr->second->Tick(a_Dt);
|
||||||
@ -360,6 +372,17 @@ void cRoot::TickWorlds(float a_Dt)
|
|||||||
|
|
||||||
|
|
||||||
void cRoot::ExecuteConsoleCommand(const AString & a_Cmd)
|
void cRoot::ExecuteConsoleCommand(const AString & a_Cmd)
|
||||||
|
{
|
||||||
|
// Put the command into a queue (Alleviates FS #363):
|
||||||
|
cCSLock Lock(m_CSPendingCommands);
|
||||||
|
m_PendingCommands.push_back(a_Cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void cRoot::DoExecuteConsoleCommand(const AString & a_Cmd)
|
||||||
{
|
{
|
||||||
LOG("Executing console command: \"%s\"", a_Cmd.c_str());
|
LOG("Executing console command: \"%s\"", a_Cmd.c_str());
|
||||||
m_Server->ExecuteConsoleCommand(a_Cmd);
|
m_Server->ExecuteConsoleCommand(a_Cmd);
|
||||||
|
@ -62,7 +62,7 @@ public:
|
|||||||
cPluginManager * GetPluginManager (void) { return m_PluginManager; } // tolua_export
|
cPluginManager * GetPluginManager (void) { return m_PluginManager; } // tolua_export
|
||||||
cAuthenticator & GetAuthenticator (void) { return m_Authenticator; }
|
cAuthenticator & GetAuthenticator (void) { return m_Authenticator; }
|
||||||
|
|
||||||
/// Executes a console command through the cServer class; does special handling for "stop" and "restart".
|
/// Queues a console command for execution through the cServer class; does special handling for "stop" and "restart".
|
||||||
void ExecuteConsoleCommand(const AString & a_Cmd); // tolua_export
|
void ExecuteConsoleCommand(const AString & a_Cmd); // tolua_export
|
||||||
|
|
||||||
/// Kicks the user, no matter in what world they are. Used from cAuthenticator
|
/// Kicks the user, no matter in what world they are. Used from cAuthenticator
|
||||||
@ -89,19 +89,14 @@ public:
|
|||||||
static AString GetProtocolVersionTextFromInt(int a_ProtocolVersionNum); // tolua_export
|
static AString GetProtocolVersionTextFromInt(int a_ProtocolVersionNum); // tolua_export
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void LoadGlobalSettings();
|
typedef std::map< AString, cWorld* > WorldMap;
|
||||||
|
cWorld* m_pDefaultWorld;
|
||||||
|
WorldMap m_WorldsByName;
|
||||||
|
|
||||||
/// Loads the worlds from settings.ini, creates the worldmap
|
cCriticalSection m_CSPendingCommands;
|
||||||
void LoadWorlds(void);
|
AStringVector m_PendingCommands;
|
||||||
|
|
||||||
/// Starts each world's life
|
cThread * m_InputThread;
|
||||||
void StartWorlds(void);
|
|
||||||
|
|
||||||
/// Stops each world's threads, so that it's safe to unload them
|
|
||||||
void StopWorlds(void);
|
|
||||||
|
|
||||||
/// Unloads all worlds from memory
|
|
||||||
void UnloadWorlds(void);
|
|
||||||
|
|
||||||
cServer * m_Server;
|
cServer * m_Server;
|
||||||
cMonsterConfig * m_MonsterConfig;
|
cMonsterConfig * m_MonsterConfig;
|
||||||
@ -118,11 +113,23 @@ private:
|
|||||||
bool m_bStop;
|
bool m_bStop;
|
||||||
bool m_bRestart;
|
bool m_bRestart;
|
||||||
|
|
||||||
typedef std::map< AString, cWorld* > WorldMap;
|
void LoadGlobalSettings();
|
||||||
cWorld* m_pDefaultWorld;
|
|
||||||
WorldMap m_WorldsByName;
|
/// Loads the worlds from settings.ini, creates the worldmap
|
||||||
|
void LoadWorlds(void);
|
||||||
|
|
||||||
|
/// Starts each world's life
|
||||||
|
void StartWorlds(void);
|
||||||
|
|
||||||
|
/// Stops each world's threads, so that it's safe to unload them
|
||||||
|
void StopWorlds(void);
|
||||||
|
|
||||||
|
/// Unloads all worlds from memory
|
||||||
|
void UnloadWorlds(void);
|
||||||
|
|
||||||
|
/// Does the actual work of executing a command
|
||||||
|
void DoExecuteConsoleCommand(const AString & a_Cmd);
|
||||||
|
|
||||||
cThread* m_InputThread;
|
|
||||||
static void InputThread(void* a_Params);
|
static void InputThread(void* a_Params);
|
||||||
|
|
||||||
static cRoot* s_Root;
|
static cRoot* s_Root;
|
||||||
|
Loading…
Reference in New Issue
Block a user