summaryrefslogtreecommitdiffstats
path: root/src/OSSupport/SocketThreads.cpp
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-12-03 16:14:26 +0100
committerMattes D <github@xoft.cz>2014-12-03 16:14:26 +0100
commit010546051e60856cfaeebbf60e1fc641d467c566 (patch)
tree3fd7592c5abcc2d75fa58dd99ba3f2380fac8e83 /src/OSSupport/SocketThreads.cpp
parentMerge pull request #1646 from p-mcgowan/luaCheckstyleWarnings (diff)
downloadcuberite-010546051e60856cfaeebbf60e1fc641d467c566.tar
cuberite-010546051e60856cfaeebbf60e1fc641d467c566.tar.gz
cuberite-010546051e60856cfaeebbf60e1fc641d467c566.tar.bz2
cuberite-010546051e60856cfaeebbf60e1fc641d467c566.tar.lz
cuberite-010546051e60856cfaeebbf60e1fc641d467c566.tar.xz
cuberite-010546051e60856cfaeebbf60e1fc641d467c566.tar.zst
cuberite-010546051e60856cfaeebbf60e1fc641d467c566.zip
Diffstat (limited to '')
-rw-r--r--src/OSSupport/SocketThreads.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/OSSupport/SocketThreads.cpp b/src/OSSupport/SocketThreads.cpp
index 7a3ef4274..153d6ed1d 100644
--- a/src/OSSupport/SocketThreads.cpp
+++ b/src/OSSupport/SocketThreads.cpp
@@ -86,7 +86,8 @@ void cSocketThreads::RemoveClient(const cCallback * a_Client)
}
} // for itr - m_Threads[]
- ASSERT(!"Removing an unknown client");
+ // This client wasn't found.
+ // It's not an error, because it may have been removed by a different thread in the meantime.
}
@@ -491,10 +492,17 @@ void cSocketThreads::cSocketThread::ReadFromSockets(fd_set * a_Read)
{
case sSlot::ssNormal:
{
- // Notify the callback that the remote has closed the socket; keep the slot
- m_Slots[i].m_Client->SocketClosed();
+ // Close the socket on our side:
m_Slots[i].m_State = sSlot::ssRemoteClosed;
m_Slots[i].m_Socket.CloseSocket();
+
+ // Notify the callback that the remote has closed the socket, *after* removing the socket:
+ cCallback * client = m_Slots[i].m_Client;
+ m_Slots[i] = m_Slots[--m_NumSlots];
+ if (client != nullptr)
+ {
+ client->SocketClosed();
+ }
break;
}
case sSlot::ssWritingRestOut: