Rewritten most of the code for multithreading; still not 100%, but getting there. If this commit proves to be too problematic, we can always undo it.
git-svn-id: http://mc-server.googlecode.com/svn/trunk@251 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
#include "Globals.h"
|
||||
#include "cSocketThreads.h"
|
||||
#include "cClientHandle.h"
|
||||
#include "packets/cPacket_RelativeEntityMoveLook.h"
|
||||
// #include "packets/cPacket_RelativeEntityMoveLook.h"
|
||||
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
cSocketThreads::cSocketThreads(void)
|
||||
{
|
||||
LOG("cSocketThreads startup");
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +61,7 @@ bool cSocketThreads::AddClient(cSocket * a_Socket, cCallback * a_Client)
|
||||
if (!Thread->Start())
|
||||
{
|
||||
// There was an error launching the thread (but it was already logged along with the reason)
|
||||
LOGERROR("A new cSocketThread failed to start");
|
||||
delete Thread;
|
||||
return false;
|
||||
}
|
||||
@@ -141,6 +143,17 @@ cSocketThreads::cSocketThread::cSocketThread(cSocketThreads * a_Parent) :
|
||||
|
||||
|
||||
|
||||
cSocketThreads::cSocketThread::~cSocketThread()
|
||||
{
|
||||
mShouldTerminate = true;
|
||||
m_ControlSocket1.CloseSocket();
|
||||
m_ControlSocket2.CloseSocket();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void cSocketThreads::cSocketThread::AddClient(cSocket * a_Socket, cCallback * a_Client)
|
||||
{
|
||||
assert(m_NumSlots < MAX_SLOTS); // Use HasEmptySlot() to check before adding
|
||||
@@ -310,6 +323,7 @@ bool cSocketThreads::cSocketThread::Start(void)
|
||||
// Start the thread
|
||||
if (!super::Start())
|
||||
{
|
||||
LOGERROR("Cannot start new cSocketThread");
|
||||
m_ControlSocket2.CloseSocket();
|
||||
return false;
|
||||
}
|
||||
@@ -383,8 +397,6 @@ void cSocketThreads::cSocketThread::Execute(void)
|
||||
|
||||
RemoveClosedSockets();
|
||||
} // while (!mShouldTerminate)
|
||||
|
||||
LOG("cSocketThread %p is terminating", this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user