From 4f17362aeb80e5339c58a5d3b0fbaeb88d9e701c Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Mon, 13 Feb 2012 21:47:03 +0000 Subject: 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 --- source/cSocketThreads.cpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'source/cSocketThreads.cpp') diff --git a/source/cSocketThreads.cpp b/source/cSocketThreads.cpp index 796316878..9d9258499 100644 --- a/source/cSocketThreads.cpp +++ b/source/cSocketThreads.cpp @@ -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); } -- cgit v1.2.3