summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-04-30 17:41:14 +0000
committerrubidium <rubidium@openttd.org>2011-04-30 17:41:14 +0000
commitc2ac411e695d1040c669524fcec6ee81e8979110 (patch)
treeb3a13b418f9dde224a5cd81af6599d1f49daf8e6 /src/network
parentbdc8a59ff4f3da26d2f96d29ec123d2f16f30fe1 (diff)
downloadopenttd-c2ac411e695d1040c669524fcec6ee81e8979110.tar.xz
(svn r22387) -Fix-ish [FS#4601]: Windows' recv seems to return "graceful closed" before having passed the remaining buffer which causes OpenTTD to think all connections are "incorrectly" terminated, i.e. without the "I'm leaving" packet from the client. So let the client wait a tiny bit after sending the "I'm leaving" packet and before gracefully closing the connection
Diffstat (limited to 'src/network')
-rw-r--r--src/network/network_client.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp
index 3cdf5c5c3..35741f09a 100644
--- a/src/network/network_client.cpp
+++ b/src/network/network_client.cpp
@@ -25,6 +25,7 @@
#include "../company_gui.h"
#include "../core/random_func.hpp"
#include "../date_func.h"
+#include "../gfx_func.h"
#include "../gui.h"
#include "../rev.h"
#include "network.h"
@@ -152,6 +153,12 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::CloseConnection(NetworkRecvSta
this->SendPackets(true);
+ /* Wait a number of ticks so our leave message can reach the server.
+ * This is especially needed for Windows servers as they seem to get
+ * the "socket is closed" message before receiving our leave message,
+ * which would trigger the server to close the connection as well. */
+ CSleep(3 * MILLISECONDS_PER_TICK);
+
delete this->GetInfo();
delete this;