summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLogicParrot <LogicParrot@users.noreply.github.com>2016-04-23 10:41:52 +0200
committerLogicParrot <LogicParrot@users.noreply.github.com>2016-04-23 10:41:52 +0200
commiteb8e9325402a4045dd4987a8193e0c21b334ec0d (patch)
tree461274297825de3958ee63cd236e319acd652bab
parentMerge pull request #3090 from LogicParrot/outOfWorld (diff)
parentClientHandle destruction thread safety (diff)
downloadcuberite-eb8e9325402a4045dd4987a8193e0c21b334ec0d.tar
cuberite-eb8e9325402a4045dd4987a8193e0c21b334ec0d.tar.gz
cuberite-eb8e9325402a4045dd4987a8193e0c21b334ec0d.tar.bz2
cuberite-eb8e9325402a4045dd4987a8193e0c21b334ec0d.tar.lz
cuberite-eb8e9325402a4045dd4987a8193e0c21b334ec0d.tar.xz
cuberite-eb8e9325402a4045dd4987a8193e0c21b334ec0d.tar.zst
cuberite-eb8e9325402a4045dd4987a8193e0c21b334ec0d.zip
-rw-r--r--src/ClientHandle.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/ClientHandle.cpp b/src/ClientHandle.cpp
index 6dc35fe61..10fc66b21 100644
--- a/src/ClientHandle.cpp
+++ b/src/ClientHandle.cpp
@@ -174,7 +174,7 @@ void cClientHandle::Destroy(void)
cWorld * World = m_Player->GetWorld();
if (World != nullptr)
{
- World->RemovePlayer(m_Player, true); // TODO this is NOT thread safe.
+ World->RemovePlayer(m_Player, true);
}
m_Player->RemoveClientHandle();
}
@@ -3082,7 +3082,18 @@ void cClientHandle::SocketClosed(void)
LOGD("Client %s @ %s disconnected", m_Username.c_str(), m_IPString.c_str());
cRoot::Get()->GetPluginManager()->CallHookDisconnect(*this, "Player disconnected");
}
- Destroy();
+ if (m_Player != nullptr)
+ {
+ m_Player->GetWorld()->ScheduleTask(1, [this](cWorld & World)
+ {
+ UNUSED(World);
+ Destroy();
+ });
+ }
+ else
+ {
+ Destroy();
+ }
}