From 168539da08f7e25fe7e42f0d89319ebe81a858ad Mon Sep 17 00:00:00 2001 From: Dennis Andersen Date: Tue, 4 Feb 2014 16:27:18 +0100 Subject: [PATCH] Gameserver - Fixed minor merging isues --- Code/Misc/ThreadSafeQueue.h | 11 +++++++++++ Code/Network/NetworkAPI/NetworkClient.cpp | 6 +++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Code/Misc/ThreadSafeQueue.h b/Code/Misc/ThreadSafeQueue.h index 2bbd042f..eaed9516 100644 --- a/Code/Misc/ThreadSafeQueue.h +++ b/Code/Misc/ThreadSafeQueue.h @@ -34,6 +34,8 @@ namespace Utility virtual bool IsEmpty(); virtual void Swap( IQueue &queue ); + virtual void Clear(); + private: class Node { @@ -216,6 +218,15 @@ namespace Utility stdMutex.unlock(); } + template < typename Type > + void ThreadSafeQueue::Clear() + { + while (!IsEmpty()) + { + Pop(); + } + } + } } diff --git a/Code/Network/NetworkAPI/NetworkClient.cpp b/Code/Network/NetworkAPI/NetworkClient.cpp index 4d9397bd..bea8c36d 100644 --- a/Code/Network/NetworkAPI/NetworkClient.cpp +++ b/Code/Network/NetworkAPI/NetworkClient.cpp @@ -62,9 +62,10 @@ struct NetworkClient::PrivateData : public IThreadObject } ~PrivateData() { + this->thread.Terminate(); + ShutdownWinSock(); this->connection.Disconnect(); - this->thread.Terminate(); this->owner = 0; this->parent = 0; } @@ -296,8 +297,11 @@ void NetworkClient::Disconnect() { if(!privateData) return; + this->privateData->sendQueue.Clear(); + privateData->connection.Disconnect(); privateData->thread.Terminate(); + } void NetworkClient::Send(CustomProtocolObject& protocol)