mirror of https://github.com/OpenTTD/OpenTTD
(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.
parent
83c8c562bb
commit
f89d6bea0e
|
@ -81,8 +81,9 @@ void NetworkTCPSocketHandler::Send_Packet(Packet *packet)
|
||||||
* 2) the OS reports back that it can not send any more
|
* 2) the OS reports back that it can not send any more
|
||||||
* data right now (full network-buffer, it happens ;))
|
* data right now (full network-buffer, it happens ;))
|
||||||
* 3) sending took too long
|
* 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;
|
ssize_t res;
|
||||||
Packet *p;
|
Packet *p;
|
||||||
|
@ -98,15 +99,17 @@ bool NetworkTCPSocketHandler::Send_Packets()
|
||||||
int err = GET_LAST_ERROR();
|
int err = GET_LAST_ERROR();
|
||||||
if (err != EWOULDBLOCK) {
|
if (err != EWOULDBLOCK) {
|
||||||
/* Something went wrong.. close client! */
|
/* Something went wrong.. close client! */
|
||||||
DEBUG(net, 0, "send failed with error %d", err);
|
if (!closing_down) {
|
||||||
this->CloseConnection();
|
DEBUG(net, 0, "send failed with error %d", err);
|
||||||
|
this->CloseConnection();
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (res == 0) {
|
if (res == 0) {
|
||||||
/* Client/server has left us :( */
|
/* Client/server has left us :( */
|
||||||
this->CloseConnection();
|
if (!closing_down) this->CloseConnection();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,7 @@ public:
|
||||||
|
|
||||||
virtual NetworkRecvStatus CloseConnection(bool error = true);
|
virtual NetworkRecvStatus CloseConnection(bool error = true);
|
||||||
void Send_Packet(Packet *packet);
|
void Send_Packet(Packet *packet);
|
||||||
bool Send_Packets();
|
bool Send_Packets(bool closing_down = false);
|
||||||
bool IsPacketQueueEmpty();
|
bool IsPacketQueueEmpty();
|
||||||
|
|
||||||
Packet *Recv_Packet();
|
Packet *Recv_Packet();
|
||||||
|
|
|
@ -571,6 +571,8 @@ void NetworkCloseClient(NetworkClientSocket *cs, bool error)
|
||||||
SetWindowDirty(WC_CLIENT_LIST, 0);
|
SetWindowDirty(WC_CLIENT_LIST, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cs->Send_Packets(true);
|
||||||
|
|
||||||
delete cs->GetInfo();
|
delete cs->GetInfo();
|
||||||
delete cs;
|
delete cs;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue