summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-03-08 16:14:14 +0000
committerrubidium <rubidium@openttd.org>2009-03-08 16:14:14 +0000
commit880d296b25bc68155ae341c256da5bc0fbbe94e5 (patch)
tree0b11045d12891665ce7c0422690d8bca8e749547
parente57699d8c0eea4021e84e61e93455bdf47139dad (diff)
downloadopenttd-880d296b25bc68155ae341c256da5bc0fbbe94e5.tar.xz
(svn r15644) -Fix [FS#2710]: closing a network connection twice in the case that sending packets starts failing while disconnecting
-rw-r--r--src/network/network.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/network/network.cpp b/src/network/network.cpp
index 542d4f52c..f3b036592 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -422,7 +422,14 @@ static NetworkClientSocket *NetworkAllocClient(SOCKET s)
// Close a connection
void NetworkCloseClient(NetworkClientSocket *cs)
{
- assert(cs->sock != INVALID_SOCKET);
+ /*
+ * Sending a message just before leaving the game calls cs->Send_Packets.
+ * This might invoke this function, which means that when we close the
+ * connection after cs->Send_Packets we will close an already closed
+ * connection. This handles that case gracefully without having to make
+ * that code any more complex or more aware of the validity of the socket.
+ */
+ if (cs->sock == INVALID_SOCKET) return;
DEBUG(net, 1, "Closed client connection %d", cs->client_id);