aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-10-14 12:39:25 +0300
committerPerttu Ahola <celeron55@gmail.com>2011-10-14 12:39:25 +0300
commit080002f8ed1af6d34cdc6f5abff0f51586ca831c (patch)
tree7871804bd919a0ca02b7e0c6d60d3d0427c57e21 /src
parent853a78681eea74103b5fd6294a2ef25e65a7f946 (diff)
downloadminetest-080002f8ed1af6d34cdc6f5abff0f51586ca831c.tar.gz
minetest-080002f8ed1af6d34cdc6f5abff0f51586ca831c.tar.bz2
minetest-080002f8ed1af6d34cdc6f5abff0f51586ca831c.zip
Lock mutex when accessing m_env in Server::~Server
Diffstat (limited to 'src')
-rw-r--r--src/server.cpp28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/server.cpp b/src/server.cpp
index 73df81dde..5b9903f5a 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -1139,19 +1139,23 @@ Server::~Server()
{}
}
}
+
+ {
+ JMutexAutoLock envlock(m_env_mutex);
- /*
- Save players
- */
- dstream<<"Server: Saving players"<<std::endl;
- m_env.serializePlayers(m_mapsavedir);
+ /*
+ 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);
-
+ /*
+ Save environment metadata
+ */
+ dstream<<"Server: Saving environment metadata"<<std::endl;
+ m_env.saveMeta(m_mapsavedir);
+ }
+
/*
Stop threads
*/
@@ -1201,6 +1205,8 @@ void Server::start(unsigned short port)
void Server::stop()
{
DSTACK(__FUNCTION_NAME);
+
+ dout_server<<"Server: Stopping and waiting threads"<<std::endl;
// Stop threads (set run=false first so both start stopping)
m_thread.setRun(false);