First attempt at fixing the inter-threading deadlocks between the tick thread and the socket thread
git-svn-id: http://mc-server.googlecode.com/svn/trunk@1591 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
parent
92fc62fb4b
commit
a67760f7c9
@ -299,6 +299,9 @@ public:
|
|||||||
/// Queues the specified block for ticking (block update)
|
/// Queues the specified block for ticking (block update)
|
||||||
void QueueTickBlock(int a_BlockX, int a_BlockY, int a_BlockZ);
|
void QueueTickBlock(int a_BlockX, int a_BlockY, int a_BlockZ);
|
||||||
|
|
||||||
|
/// Returns the CS for locking the chunkmap; only cWorld::cLock may use this function!
|
||||||
|
cCriticalSection & GetCS(void) { return m_CSLayers; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
friend class cChunk; // The chunks can manipulate neighbors while in their Tick() method, using LockedGetBlock() and LockedSetBlock()
|
friend class cChunk; // The chunks can manipulate neighbors while in their Tick() method, using LockedGetBlock() and LockedSetBlock()
|
||||||
|
@ -1957,7 +1957,17 @@ void cClientHandle::PacketError(unsigned char a_PacketType)
|
|||||||
void cClientHandle::DataReceived(const char * a_Data, int a_Size)
|
void cClientHandle::DataReceived(const char * a_Data, int a_Size)
|
||||||
{
|
{
|
||||||
// Data is received from the client, hand it off to the protocol:
|
// Data is received from the client, hand it off to the protocol:
|
||||||
|
if ((m_Player != NULL) && (m_Player->GetWorld() != NULL))
|
||||||
|
{
|
||||||
|
// Lock the world, so that plugins reacting to protocol events have already the chunkmap locked
|
||||||
|
cWorld::cLock(*m_Player->GetWorld());
|
||||||
|
|
||||||
m_Protocol->DataReceived(a_Data, a_Size);
|
m_Protocol->DataReceived(a_Data, a_Size);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
m_Protocol->DataReceived(a_Data, a_Size);
|
||||||
|
}
|
||||||
m_TimeSinceLastPacket = 0;
|
m_TimeSinceLastPacket = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,6 +172,18 @@ protected:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// cWorld::cLock:
|
||||||
|
|
||||||
|
cWorld::cLock::cLock(cWorld & a_World) :
|
||||||
|
super(&(a_World.m_ChunkMap->GetCS()))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// cWorld:
|
// cWorld:
|
||||||
|
|
||||||
|
@ -66,6 +66,19 @@ public:
|
|||||||
dimEnd = 1,
|
dimEnd = 1,
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
|
// tolua_end
|
||||||
|
|
||||||
|
/// A simple RAII locker for the chunkmap - locks the chunkmap in its constructor, unlocks it in the destructor
|
||||||
|
class cLock :
|
||||||
|
public cCSLock
|
||||||
|
{
|
||||||
|
typedef cCSLock super;
|
||||||
|
public:
|
||||||
|
cLock(cWorld & a_World);
|
||||||
|
} ;
|
||||||
|
|
||||||
|
// tolua_begin
|
||||||
|
|
||||||
static const char * GetClassStatic(void)
|
static const char * GetClassStatic(void)
|
||||||
{
|
{
|
||||||
return "cWorld";
|
return "cWorld";
|
||||||
|
Loading…
Reference in New Issue
Block a user