summaryrefslogtreecommitdiffstats
path: root/source/cClientHandle.cpp
diff options
context:
space:
mode:
authormadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-08-31 18:26:03 +0200
committermadmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2012-08-31 18:26:03 +0200
commitacc4be80348ec1a774481d7ee3b8b207174a91a7 (patch)
tree08b1200a2e24ef4c82bd7c1e1c004665c7d69664 /source/cClientHandle.cpp
parentFixed one possibility of a deadlock in cClientHandle::SendChunkData() (diff)
downloadcuberite-acc4be80348ec1a774481d7ee3b8b207174a91a7.tar
cuberite-acc4be80348ec1a774481d7ee3b8b207174a91a7.tar.gz
cuberite-acc4be80348ec1a774481d7ee3b8b207174a91a7.tar.bz2
cuberite-acc4be80348ec1a774481d7ee3b8b207174a91a7.tar.lz
cuberite-acc4be80348ec1a774481d7ee3b8b207174a91a7.tar.xz
cuberite-acc4be80348ec1a774481d7ee3b8b207174a91a7.tar.zst
cuberite-acc4be80348ec1a774481d7ee3b8b207174a91a7.zip
Diffstat (limited to 'source/cClientHandle.cpp')
-rw-r--r--source/cClientHandle.cpp18
1 files changed, 13 insertions, 5 deletions
diff --git a/source/cClientHandle.cpp b/source/cClientHandle.cpp
index 4db64cfde..29446615f 100644
--- a/source/cClientHandle.cpp
+++ b/source/cClientHandle.cpp
@@ -94,6 +94,7 @@ cClientHandle::cClientHandle(const cSocket & a_Socket, int a_ViewDistance)
, m_State(csConnected)
, m_LastStreamedChunkX(0x7fffffff) // bogus chunk coords to force streaming upon login
, m_LastStreamedChunkZ(0x7fffffff)
+ , m_ShouldCheckDownloaded(false)
, m_UniqueID(0)
{
m_Protocol = new cProtocolRecognizer(this);
@@ -923,8 +924,9 @@ void cClientHandle::SendData(const char * a_Data, int a_Size)
cCSLock Lock(m_CSOutgoingData);
if (!m_OutgoingData.Write(a_Data, a_Size))
{
- // Client has too much outgoing data queued, drop them silently:
- Destroy();
+ // Client has too much outgoing data queued, drop them silently by timing them out:
+ // (So that they're dropped in the tick thread and not the sender thread)
+ m_LastPingTime = 0;
}
}
@@ -979,6 +981,12 @@ void cClientHandle::Tick(float a_Dt)
Destroy();
}
+ if ((m_State == csDownloadingWorld) && m_ShouldCheckDownloaded)
+ {
+ CheckIfWorldDownloaded();
+ m_ShouldCheckDownloaded = false;
+ }
+
cTimer t1;
// Send ping packet
if (
@@ -1359,9 +1367,9 @@ void cClientHandle::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializ
{
m_ChunksToSend.erase(itr);
- // TODO: _X: Decouple this from packet sending, it creates a deadlock possibility
- // -- postpone till Tick() instead, using a bool flag
- CheckIfWorldDownloaded();
+ // Make the tick thread check if all the needed chunks have been downloaded
+ // -- needed to offload this from here due to a deadlock possibility
+ m_ShouldCheckDownloaded = true;
Found = true;
break;