1
0

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
This commit is contained in:
madmaxoft@gmail.com 2012-08-31 16:26:03 +00:00
parent f8b2cd99a6
commit acc4be8034
2 changed files with 16 additions and 5 deletions

View File

@ -94,6 +94,7 @@ cClientHandle::cClientHandle(const cSocket & a_Socket, int a_ViewDistance)
, m_State(csConnected) , m_State(csConnected)
, m_LastStreamedChunkX(0x7fffffff) // bogus chunk coords to force streaming upon login , m_LastStreamedChunkX(0x7fffffff) // bogus chunk coords to force streaming upon login
, m_LastStreamedChunkZ(0x7fffffff) , m_LastStreamedChunkZ(0x7fffffff)
, m_ShouldCheckDownloaded(false)
, m_UniqueID(0) , m_UniqueID(0)
{ {
m_Protocol = new cProtocolRecognizer(this); m_Protocol = new cProtocolRecognizer(this);
@ -923,8 +924,9 @@ void cClientHandle::SendData(const char * a_Data, int a_Size)
cCSLock Lock(m_CSOutgoingData); cCSLock Lock(m_CSOutgoingData);
if (!m_OutgoingData.Write(a_Data, a_Size)) if (!m_OutgoingData.Write(a_Data, a_Size))
{ {
// Client has too much outgoing data queued, drop them silently: // Client has too much outgoing data queued, drop them silently by timing them out:
Destroy(); // (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(); Destroy();
} }
if ((m_State == csDownloadingWorld) && m_ShouldCheckDownloaded)
{
CheckIfWorldDownloaded();
m_ShouldCheckDownloaded = false;
}
cTimer t1; cTimer t1;
// Send ping packet // Send ping packet
if ( if (
@ -1359,9 +1367,9 @@ void cClientHandle::SendChunkData(int a_ChunkX, int a_ChunkZ, cChunkDataSerializ
{ {
m_ChunksToSend.erase(itr); m_ChunksToSend.erase(itr);
// TODO: _X: Decouple this from packet sending, it creates a deadlock possibility // Make the tick thread check if all the needed chunks have been downloaded
// -- postpone till Tick() instead, using a bool flag // -- needed to offload this from here due to a deadlock possibility
CheckIfWorldDownloaded(); m_ShouldCheckDownloaded = true;
Found = true; Found = true;
break; break;

View File

@ -223,6 +223,9 @@ private:
eState m_State; eState m_State;
bool m_bKeepThreadGoing; bool m_bKeepThreadGoing;
/// If set to true during csDownloadingWorld, the tick thread calls CheckIfWorldDownloaded()
bool m_ShouldCheckDownloaded;
/// Returns true if the rate block interactions is within a reasonable limit (bot protection) /// Returns true if the rate block interactions is within a reasonable limit (bot protection)
bool CheckBlockInteractionsRate(void); bool CheckBlockInteractionsRate(void);