summaryrefslogtreecommitdiff
path: root/src/network
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-01-14 21:48:42 +0000
committerrubidium <rubidium@openttd.org>2010-01-14 21:48:42 +0000
commitf89d6bea0ef8d198027c7bcaed5c457aaa228330 (patch)
treea650f94741f7657fb9fdf56f315319b46b64602b /src/network
parent83c8c562bbe006df262bd58d6ab349e3ea3f5349 (diff)
downloadopenttd-f89d6bea0ef8d198027c7bcaed5c457aaa228330.tar.xz
(svn r18801) -Fix: in some cases error messages weren't properly sent to the client before closing the connection. As a result the client would say 'connection lost' when the cause was something completely different.
Diffstat (limited to 'src/network')
-rw-r--r--src/network/core/tcp.cpp11
-rw-r--r--src/network/core/tcp.h2
-rw-r--r--src/network/network.cpp2
3 files changed, 10 insertions, 5 deletions
diff --git a/src/network/core/tcp.cpp b/src/network/core/tcp.cpp
index c3a7733e3..39f90569f 100644
--- a/src/network/core/tcp.cpp
+++ b/src/network/core/tcp.cpp
@@ -81,8 +81,9 @@ void NetworkTCPSocketHandler::Send_Packet(Packet *packet)
* 2) the OS reports back that it can not send any more
* data right now (full network-buffer, it happens ;))
* 3) sending took too long
+ * @param closing_down Whether we are closing down the connection.
*/
-bool NetworkTCPSocketHandler::Send_Packets()
+bool NetworkTCPSocketHandler::Send_Packets(bool closing_down)
{
ssize_t res;
Packet *p;
@@ -98,15 +99,17 @@ bool NetworkTCPSocketHandler::Send_Packets()
int err = GET_LAST_ERROR();
if (err != EWOULDBLOCK) {
/* Something went wrong.. close client! */
- DEBUG(net, 0, "send failed with error %d", err);
- this->CloseConnection();
+ if (!closing_down) {
+ DEBUG(net, 0, "send failed with error %d", err);
+ this->CloseConnection();
+ }
return false;
}
return true;
}
if (res == 0) {
/* Client/server has left us :( */
- this->CloseConnection();
+ if (!closing_down) this->CloseConnection();
return false;
}
diff --git a/src/network/core/tcp.h b/src/network/core/tcp.h
index 904db99c4..b24e241f1 100644
--- a/src/network/core/tcp.h
+++ b/src/network/core/tcp.h
@@ -38,7 +38,7 @@ public:
virtual NetworkRecvStatus CloseConnection(bool error = true);
void Send_Packet(Packet *packet);
- bool Send_Packets();
+ bool Send_Packets(bool closing_down = false);
bool IsPacketQueueEmpty();
Packet *Recv_Packet();
diff --git a/src/network/network.cpp b/src/network/network.cpp
index cf67ca1fa..899ca88c8 100644
--- a/src/network/network.cpp
+++ b/src/network/network.cpp
@@ -571,6 +571,8 @@ void NetworkCloseClient(NetworkClientSocket *cs, bool error)
SetWindowDirty(WC_CLIENT_LIST, 0);
}
+ cs->Send_Packets(true);
+
delete cs->GetInfo();
delete cs;
}