Browse Source

Don't send a second FIN if we receive a FIN while in FIN_WAIT_2

tags/v0.9.3
Michael Brown 18 years ago
parent
commit
be31970e36
1 changed files with 6 additions and 5 deletions
  1. 6
    5
      src/net/tcp.c

+ 6
- 5
src/net/tcp.c View File

573
 	if ( ( conn->rcv_ack - seq ) > 0 )
573
 	if ( ( conn->rcv_ack - seq ) > 0 )
574
 		return 0;
574
 		return 0;
575
 
575
 
576
-	/* Mark FIN as received and send our own FIN */
577
-	conn->tcp_state |= ( TCP_STATE_RCVD ( TCP_FIN ) |
578
-			     TCP_STATE_SENDING ( TCP_FIN ) );
579
-
580
-	/* Acknowledge FIN */
576
+	/* Mark FIN as received and acknowledge it */
577
+	conn->tcp_state |= TCP_STATE_RCVD ( TCP_FIN );
581
 	conn->rcv_ack++;
578
 	conn->rcv_ack++;
582
 
579
 
580
+	/* If we haven't already sent our FIN, send a FIN */
581
+	if ( ! ( conn->tcp_state & TCP_STATE_ACKED ( TCP_FIN ) ) )
582
+		conn->tcp_state |= TCP_STATE_SENDING ( TCP_FIN );
583
+
583
 	/* Break association with application */
584
 	/* Break association with application */
584
 	tcp_disassociate ( conn );
585
 	tcp_disassociate ( conn );
585
 
586
 

Loading…
Cancel
Save