mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Socket: Removed unused synchronous read method
This commit is contained in:
@@ -81,8 +81,8 @@ void WorldSocket::Start()
|
||||
initializer.Write(&header, sizeof(header.Setup.Size));
|
||||
initializer.Write(ServerConnectionInitialize.c_str(), ServerConnectionInitialize.length());
|
||||
|
||||
std::unique_lock<std::mutex> dummy(_writeLock, std::defer_lock);
|
||||
QueuePacket(std::move(initializer), dummy);
|
||||
std::unique_lock<std::mutex> guard(_writeLock);
|
||||
QueuePacket(std::move(initializer), guard);
|
||||
}
|
||||
|
||||
void WorldSocket::HandleSendAuthSession()
|
||||
|
||||
@@ -50,6 +50,7 @@ public:
|
||||
|
||||
virtual ~Socket()
|
||||
{
|
||||
_closed = true;
|
||||
boost::system::error_code error;
|
||||
_socket.close(error);
|
||||
}
|
||||
@@ -97,26 +98,6 @@ public:
|
||||
std::bind(&Socket<T>::ReadHandlerInternal, this->shared_from_this(), std::placeholders::_1, std::placeholders::_2));
|
||||
}
|
||||
|
||||
void ReadData(std::size_t size)
|
||||
{
|
||||
if (!IsOpen())
|
||||
return;
|
||||
|
||||
boost::system::error_code error;
|
||||
|
||||
std::size_t bytesRead = boost::asio::read(_socket, boost::asio::buffer(_readBuffer.GetWritePointer(), size), error);
|
||||
|
||||
_readBuffer.WriteCompleted(bytesRead);
|
||||
|
||||
if (error || bytesRead != size)
|
||||
{
|
||||
TC_LOG_DEBUG("network", "Socket::ReadData: %s errored with: %i (%s)", GetRemoteIpAddress().to_string().c_str(), error.value(),
|
||||
error.message().c_str());
|
||||
|
||||
CloseSocket();
|
||||
}
|
||||
}
|
||||
|
||||
void QueuePacket(MessageBuffer&& buffer, std::unique_lock<std::mutex>& guard)
|
||||
{
|
||||
_writeQueue.push(std::move(buffer));
|
||||
|
||||
@@ -70,7 +70,9 @@ public:
|
||||
{
|
||||
std::unique_lock<std::mutex> lock(_queueLock);
|
||||
|
||||
_condition.wait(lock, [this]() { return !_queue.empty() || _shutdown; });
|
||||
// we could be using .wait(lock, predicate) overload here but some threading error analysis tools produce false positives
|
||||
while (_queue.empty() && !_shutdown)
|
||||
_condition.wait(lock);
|
||||
|
||||
if (_queue.empty() || _shutdown)
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user