summaryrefslogtreecommitdiffstats
path: root/src/OSSupport
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@hotmail.co.uk>2014-02-03 22:25:42 +0100
committerTiger Wang <ziwei.tiger@hotmail.co.uk>2014-02-03 22:25:42 +0100
commita3759c1462fd2fe89a545fc9ece90559b4a2469a (patch)
treedc46c925aec3e28fdb610f55245377453e67fa73 /src/OSSupport
parentFixed #626 (diff)
parentMerge pull request #623 from mc-server/tnt (diff)
downloadcuberite-a3759c1462fd2fe89a545fc9ece90559b4a2469a.tar
cuberite-a3759c1462fd2fe89a545fc9ece90559b4a2469a.tar.gz
cuberite-a3759c1462fd2fe89a545fc9ece90559b4a2469a.tar.bz2
cuberite-a3759c1462fd2fe89a545fc9ece90559b4a2469a.tar.lz
cuberite-a3759c1462fd2fe89a545fc9ece90559b4a2469a.tar.xz
cuberite-a3759c1462fd2fe89a545fc9ece90559b4a2469a.tar.zst
cuberite-a3759c1462fd2fe89a545fc9ece90559b4a2469a.zip
Diffstat (limited to 'src/OSSupport')
-rw-r--r--src/OSSupport/SocketThreads.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/OSSupport/SocketThreads.cpp b/src/OSSupport/SocketThreads.cpp
index 3e2631733..a02661d2c 100644
--- a/src/OSSupport/SocketThreads.cpp
+++ b/src/OSSupport/SocketThreads.cpp
@@ -209,6 +209,10 @@ bool cSocketThreads::cSocketThread::RemoveClient(const cCallback * a_Client)
if (m_Slots[i].m_State == sSlot::ssRemoteClosed)
{
// The remote has already closed the socket, remove the slot altogether:
+ if (m_Slots[i].m_Socket.IsValid())
+ {
+ m_Slots[i].m_Socket.CloseSocket();
+ }
m_Slots[i] = m_Slots[--m_NumSlots];
}
else
@@ -489,6 +493,7 @@ void cSocketThreads::cSocketThread::ReadFromSockets(fd_set * a_Read)
// Notify the callback that the remote has closed the socket; keep the slot
m_Slots[i].m_Client->SocketClosed();
m_Slots[i].m_State = sSlot::ssRemoteClosed;
+ m_Slots[i].m_Socket.CloseSocket();
break;
}
case sSlot::ssWritingRestOut:
@@ -557,6 +562,11 @@ void cSocketThreads::cSocketThread::WriteToSockets(fd_set * a_Write)
}
} // if (outgoing data is empty)
+ if (m_Slots[i].m_State == sSlot::ssRemoteClosed)
+ {
+ continue;
+ }
+
if (!SendDataThroughSocket(m_Slots[i].m_Socket, m_Slots[i].m_Outgoing))
{
int Err = cSocket::GetLastError();
@@ -566,7 +576,7 @@ void cSocketThreads::cSocketThread::WriteToSockets(fd_set * a_Write)
{
m_Slots[i].m_Client->SocketClosed();
}
- return;
+ continue;
}
if (m_Slots[i].m_Outgoing.empty() && (m_Slots[i].m_State == sSlot::ssWritingRestOut))