summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-12-01 02:41:52 +0200
committerPerttu Ahola <celeron55@gmail.com>2011-12-01 02:41:52 +0200
commitb6539399f43698aee41d02aa5b8ef1423d6c7da1 (patch)
tree598b3d25fb2ef18cd11ace293c9d00b8fcefc869
parent8b8ef8acc0cc0b59e231d55e7857f629fee27e66 (diff)
downloadminetest-b6539399f43698aee41d02aa5b8ef1423d6c7da1.tar.gz
minetest-b6539399f43698aee41d02aa5b8ef1423d6c7da1.tar.bz2
minetest-b6539399f43698aee41d02aa5b8ef1423d6c7da1.zip
Fix deadlock if MeshUpdateThread asks new textures while it is being stopped (happened if texture data was transferred slowly)
-rw-r--r--src/client.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 0f28087d4..fee219942 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -1519,7 +1519,12 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
std::istringstream is(datastring, std::ios_base::binary);
// Stop threads while updating content definitions
- m_mesh_update_thread.stop();
+ m_mesh_update_thread.setRun(false);
+ // Process the remaining TextureSource queue to let MeshUpdateThread
+ // get it's remaining textures and thus let it stop
+ while(m_mesh_update_thread.IsRunning()){
+ m_tsrc->processQueue();
+ }
/*
u16 command
@@ -1595,8 +1600,13 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
m_tooldef_received = true;
// Stop threads while updating content definitions
- m_mesh_update_thread.stop();
-
+ m_mesh_update_thread.setRun(false);
+ // Process the remaining TextureSource queue to let MeshUpdateThread
+ // get it's remaining textures and thus let it stop
+ while(m_mesh_update_thread.IsRunning()){
+ m_tsrc->processQueue();
+ }
+
std::istringstream tmp_is(deSerializeLongString(is), std::ios::binary);
m_tooldef->deSerialize(tmp_is);
@@ -1644,8 +1654,13 @@ void Client::ProcessData(u8 *data, u32 datasize, u16 sender_peer_id)
m_craftitemdef_received = true;
// Stop threads while updating content definitions
- m_mesh_update_thread.stop();
-
+ m_mesh_update_thread.setRun(false);
+ // Process the remaining TextureSource queue to let MeshUpdateThread
+ // get it's remaining textures and thus let it stop
+ while(m_mesh_update_thread.IsRunning()){
+ m_tsrc->processQueue();
+ }
+
std::istringstream tmp_is(deSerializeLongString(is), std::ios::binary);
m_craftitemdef->deSerialize(tmp_is);