From acc4be80348ec1a774481d7ee3b8b207174a91a7 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Fri, 31 Aug 2012 16:26:03 +0000 Subject: Another possible deadlock in cClientHandle averted. Hope this is the one. git-svn-id: http://mc-server.googlecode.com/svn/trunk@810 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cClientHandle.cpp | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'source/cClientHandle.cpp') 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; -- cgit v1.2.3