Skip to content

Commit

Permalink
Core/Networking: Fixed DelayedCloseSocket when compiled without TC_SO…
Browse files Browse the repository at this point in the history
…CKET_USE_IOCP (linux)

Closes #16769
  • Loading branch information
Shauren committed Mar 12, 2016
1 parent 16953c9 commit 0daba93
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/server/shared/Networking/Socket.h
Expand Up @@ -55,11 +55,11 @@ class Socket : public std::enable_shared_from_this<T>

virtual bool Update()
{
if (!IsOpen())
if (_closed)
return false;

#ifndef TC_SOCKET_USE_IOCP
if (_isWritingAsync || _writeQueue.empty())
if (_isWritingAsync || (_writeQueue.empty() && !_closing))
return true;

for (; HandleQueue();)
Expand Down Expand Up @@ -164,7 +164,6 @@ class Socket : public std::enable_shared_from_this<T>
GetRemoteIpAddress().to_string().c_str(), err.value(), err.message().c_str());
}


private:
void ReadHandlerInternal(boost::system::error_code error, size_t transferredBytes)
{
Expand Down Expand Up @@ -208,9 +207,6 @@ class Socket : public std::enable_shared_from_this<T>

bool HandleQueue()
{
if (!IsOpen())
return false;

if (_writeQueue.empty())
return false;

Expand All @@ -227,11 +223,15 @@ class Socket : public std::enable_shared_from_this<T>
return AsyncProcessQueue();

_writeQueue.pop();
if (_closing && _writeQueue.empty())
CloseSocket();
return false;
}
else if (bytesSent == 0)
{
_writeQueue.pop();
if (_closing && _writeQueue.empty())
CloseSocket();
return false;
}
else if (bytesSent < bytesToSend) // now n > 0
Expand All @@ -241,6 +241,8 @@ class Socket : public std::enable_shared_from_this<T>
}

_writeQueue.pop();
if (_closing && _writeQueue.empty())
CloseSocket();
return !_writeQueue.empty();
}

Expand Down

0 comments on commit 0daba93

Please sign in to comment.