Lock mutex when accessing m_env in Server::~Server

This commit is contained in:
Perttu Ahola 2011-10-14 12:39:25 +03:00
parent 853a78681e
commit 080002f8ed

@ -1139,19 +1139,23 @@ Server::~Server()
{} {}
} }
} }
/*
Save players
*/
dstream<<"Server: Saving players"<<std::endl;
m_env.serializePlayers(m_mapsavedir);
/*
Save environment metadata
*/
dstream<<"Server: Saving environment metadata"<<std::endl;
m_env.saveMeta(m_mapsavedir);
{
JMutexAutoLock envlock(m_env_mutex);
/*
Save players
*/
dstream<<"Server: Saving players"<<std::endl;
m_env.serializePlayers(m_mapsavedir);
/*
Save environment metadata
*/
dstream<<"Server: Saving environment metadata"<<std::endl;
m_env.saveMeta(m_mapsavedir);
}
/* /*
Stop threads Stop threads
*/ */
@ -1201,6 +1205,8 @@ void Server::start(unsigned short port)
void Server::stop() void Server::stop()
{ {
DSTACK(__FUNCTION_NAME); DSTACK(__FUNCTION_NAME);
dout_server<<"Server: Stopping and waiting threads"<<std::endl;
// Stop threads (set run=false first so both start stopping) // Stop threads (set run=false first so both start stopping)
m_thread.setRun(false); m_thread.setRun(false);