tcp: Fix early cancellation of timers on socket free.

TCPEndpoint::Free() uses _EnterTimeWait() to start the time-wait timer
for later cleanup. The latter did call _CancelConnectionTimers()
unconditionally however, also cancelling a retransmit timer that was
possibly still needed for the retransmission of the FIN packet. If the
FIN packet got lost, the connection would be left open on the other end.
This commit is contained in:
Michael Lotz 2015-08-02 20:42:53 +02:00
parent bc49140bab
commit 94fb06bfce
1 changed files with 8 additions and 6 deletions

View File

@ -1138,14 +1138,16 @@ TCPEndpoint::_StartPersistTimer()
void
TCPEndpoint::_EnterTimeWait()
{
TRACE("_EnterTimeWait()\n");
TRACE("_EnterTimeWait()");
_CancelConnectionTimers();
if (fState == TIME_WAIT) {
_CancelConnectionTimers();
if (fState == TIME_WAIT && IsLocal()) {
// we do not use TIME_WAIT state for local connections
fFlags |= FLAG_DELETE_ON_CLOSE;
return;
if (IsLocal()) {
// we do not use TIME_WAIT state for local connections
fFlags |= FLAG_DELETE_ON_CLOSE;
return;
}
}
_UpdateTimeWait();