Close connection if a packet can't be sent

I am still completely mystified why this seems to happen so often in
practice. Hopefully the extra logging will give us some clues in
future. And closing the connection immediately gives us a small chance
at recovering from this situation.
stable-5.3
Peter Wortmann 2013-03-02 20:51:17 +00:00 committed by Tobias Zwick
parent eabd15469f
commit cd5c5fe30c
1 changed files with 9 additions and 0 deletions

View File

@ -1495,6 +1495,15 @@ bool C4Network2IOConnection::Send(const C4NetIOPacket &rPkt)
bool fSuccess = pNetClass->Send(pLogEntry->Pkt);
if (fSuccess)
assert(!fPostMortemSent);
else {
// Not being able to send a packet is actually a big deal,
// as this means that we will have hole in the packet
// order. Better close the connection - post mortem should
// ideally sort everything out from here.
LogF("Network: Fatal: Send failed (%s)", pNetClass->GetError());
pNetClass->ResetError();
Close();
}
return fSuccess;
}