summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-28 15:58:07 +0100
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-02-28 15:58:07 +0100
commita4503ddb777f61799971e4a7f9711dbbda5bc7fd (patch)
treec2a49a98e6ea614decf619738ef264118234546a
parentServer uses ~40% less CPU now (diff)
downloadcuberite-a4503ddb777f61799971e4a7f9711dbbda5bc7fd.tar
cuberite-a4503ddb777f61799971e4a7f9711dbbda5bc7fd.tar.gz
cuberite-a4503ddb777f61799971e4a7f9711dbbda5bc7fd.tar.bz2
cuberite-a4503ddb777f61799971e4a7f9711dbbda5bc7fd.tar.lz
cuberite-a4503ddb777f61799971e4a7f9711dbbda5bc7fd.tar.xz
cuberite-a4503ddb777f61799971e4a7f9711dbbda5bc7fd.tar.zst
cuberite-a4503ddb777f61799971e4a7f9711dbbda5bc7fd.zip
-rw-r--r--source/cClientHandle.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp
index 4a6a0b508..7128b925c 100644
--- a/source/cClientHandle.cpp
+++ b/source/cClientHandle.cpp
@@ -148,8 +148,11 @@ cClientHandle::~cClientHandle()
// Remove from cSocketThreads, we're not to be called anymore:
cRoot::Get()->GetServer()->ClientDestroying(this);
- m_LoadedChunks.clear();
- m_ChunksToSend.clear();
+ {
+ cCSLock Lock(m_CSChunkLists);
+ m_LoadedChunks.clear();
+ m_ChunksToSend.clear();
+ }
if (m_Player != NULL)
{
@@ -226,12 +229,16 @@ cClientHandle::~cClientHandle()
void cClientHandle::Destroy()
{
- m_bDestroyed = true;
+ // Setting m_bDestroyed was moved to the bottom of Destroy(),
+ // otherwise the destructor may be called within another thread before the client is removed from chunks
+ // http://forum.mc-server.org/showthread.php?tid=366
if ((m_Player != NULL) && (m_Player->GetWorld() != NULL))
{
RemoveFromAllChunks();
}
+
+ m_bDestroyed = true;
}