Core/Networking: Fixed unsafe access to _worldSession member in WorldSocket

This commit is contained in:
Shauren
2015-03-28 21:45:27 +01:00
parent 801fc634b5
commit bed88e0dd4
4 changed files with 103 additions and 50 deletions

View File

@@ -62,7 +62,7 @@ public:
return false;
#ifndef TC_SOCKET_USE_IOCP
std::unique_lock<std::mutex> guard(_writeLock, std::try_to_lock);
std::unique_lock<std::mutex> guard(_writeLock);
if (!guard)
return true;
@@ -140,6 +140,8 @@ public:
if (shutdownError)
TC_LOG_DEBUG("network", "Socket::CloseSocket: %s errored when shutting down socket: %i (%s)", GetRemoteIpAddress().to_string().c_str(),
shutdownError.value(), shutdownError.message().c_str());
OnClose();
}
/// Marks the socket for closing after write buffer becomes empty
@@ -148,6 +150,8 @@ public:
MessageBuffer& GetReadBuffer() { return _readBuffer; }
protected:
virtual void OnClose() { }
virtual void ReadHandler() = 0;
bool AsyncProcessQueue(std::unique_lock<std::mutex>&)