Browse Source

Don't call stop_timer() from within the timer expiry callback; it's

already stopped.

Don't call start_timer() when sending a dataless ACK.  This may or may
not be the right thing to do; I can't tell.

Back out broken "send ACK only if required to" logic temporarily.
tags/v0.9.3
Michael Brown 18 years ago
parent
commit
f0718d562f
1 changed files with 10 additions and 11 deletions
  1. 10
    11
      src/net/tcp.c

+ 10
- 11
src/net/tcp.c View File

384
 	case TCP_SYN_SENT:
384
 	case TCP_SYN_SENT:
385
 		if ( over ) {
385
 		if ( over ) {
386
 			tcp_trans ( conn, TCP_CLOSED );
386
 			tcp_trans ( conn, TCP_CLOSED );
387
-			stop_timer ( &conn->timer );
388
 			DBG ( "Timeout! Connection closed\n" );
387
 			DBG ( "Timeout! Connection closed\n" );
389
 			return;
388
 			return;
390
 		}
389
 		}
392
 	case TCP_SYN_RCVD:
391
 	case TCP_SYN_RCVD:
393
 		if ( over ) {
392
 		if ( over ) {
394
 			tcp_trans ( conn, TCP_CLOSED );
393
 			tcp_trans ( conn, TCP_CLOSED );
395
-			stop_timer ( &conn->timer );
396
 			goto send_tcp_nomsg;
394
 			goto send_tcp_nomsg;
397
 		}
395
 		}
398
 		goto send_tcp_nomsg;
396
 		goto send_tcp_nomsg;
417
 		return;
415
 		return;
418
 	case TCP_TIME_WAIT:
416
 	case TCP_TIME_WAIT:
419
 		tcp_trans ( conn, TCP_CLOSED );
417
 		tcp_trans ( conn, TCP_CLOSED );
420
-		stop_timer ( &conn->timer );
421
 		return;
418
 		return;
422
 	}
419
 	}
423
 	/* Retransmit the data */
420
 	/* Retransmit the data */
632
 	/* Call the senddata() call back function */
629
 	/* Call the senddata() call back function */
633
 	conn->tcp_op->senddata ( conn, conn->tx_pkb->data, 
630
 	conn->tcp_op->senddata ( conn, conn->tx_pkb->data, 
634
 					pkb_available ( conn->tx_pkb ) );
631
 					pkb_available ( conn->tx_pkb ) );
632
+	/* Send pure ACK if senddata() didn't call tcp_send() */
633
+	if ( conn->tx_pkb ) {
634
+		tcp_send ( conn, TCP_NOMSG, TCP_NOMSG_LEN );
635
+	}
635
 	return 0;
636
 	return 0;
636
 }
637
 }
637
 
638
 
685
 	/* Start the timer */
686
 	/* Start the timer */
686
 	if ( ( conn->tcp_state == TCP_ESTABLISHED && conn->tcp_lstate == TCP_SYN_SENT ) ||
687
 	if ( ( conn->tcp_state == TCP_ESTABLISHED && conn->tcp_lstate == TCP_SYN_SENT ) ||
687
 	     ( conn->tcp_state == TCP_LISTEN && conn->tcp_lstate == TCP_SYN_RCVD ) ||
688
 	     ( conn->tcp_state == TCP_LISTEN && conn->tcp_lstate == TCP_SYN_RCVD ) ||
688
-	     ( conn->tcp_state == TCP_CLOSED && conn->tcp_lstate == TCP_SYN_RCVD ) ) {
689
+	     ( conn->tcp_state == TCP_CLOSED && conn->tcp_lstate == TCP_SYN_RCVD ) ||
690
+	     ( conn->tcp_state == TCP_ESTABLISHED && ( len == 0 ) ) ) {
689
 		// Don't start the timer
691
 		// Don't start the timer
690
 	} else {
692
 	} else {
691
 		start_timer ( &conn->timer );
693
 		start_timer ( &conn->timer );
912
 			      ntohl ( tcphdr->seq ), conn->rcv_nxt );
914
 			      ntohl ( tcphdr->seq ), conn->rcv_nxt );
913
 		}
915
 		}
914
 
916
 
915
-		/* Send an ACK only if required to */
916
-		if ( conn->rcv_nxt <= ntohl ( tcphdr->seq ) ) {
917
-			/* Acknowledge new data */
918
-			conn->tcp_flags |= TCP_ACK;
919
-			if ( !( tcphdr->flags & TCP_ACK ) ) {
920
-				goto send_tcp_nomsg;
921
-			}
917
+		/* Acknowledge new data */
918
+		conn->tcp_flags |= TCP_ACK;
919
+		if ( !( tcphdr->flags & TCP_ACK ) ) {
920
+			goto send_tcp_nomsg;
922
 		}
921
 		}
923
 	}
922
 	}
924
 
923
 

Loading…
Cancel
Save