Browse Source

Define "connected" as

  "when SYN is ACKed and we have already received SYN", or
  "when SYN is received and we have already had SYN ACKed"

rather than just

  "when SYN is ACKed"

This avoids spuriously calling the connected() method when we receive
a RST,ACK in response to a SYN.
tags/v0.9.3
Michael Brown 18 years ago
parent
commit
2eeb7c4fe7
1 changed files with 9 additions and 1 deletions
  1. 9
    1
      src/net/tcp.c

+ 9
- 1
src/net/tcp.c View File

492
  * @ret rc		Return status code
492
  * @ret rc		Return status code
493
  */
493
  */
494
 static int tcp_rx_syn ( struct tcp_connection *conn, uint32_t seq ) {
494
 static int tcp_rx_syn ( struct tcp_connection *conn, uint32_t seq ) {
495
+	struct tcp_application *app = conn->app;
495
 
496
 
496
 	/* Synchronise sequence numbers on first SYN */
497
 	/* Synchronise sequence numbers on first SYN */
497
 	if ( ! ( conn->tcp_state & TCP_STATE_RCVD ( TCP_SYN ) ) )
498
 	if ( ! ( conn->tcp_state & TCP_STATE_RCVD ( TCP_SYN ) ) )
508
 	/* Acknowledge SYN */
509
 	/* Acknowledge SYN */
509
 	conn->rcv_ack++;
510
 	conn->rcv_ack++;
510
 
511
 
512
+	/* Notify application of established connection, if applicable */
513
+	if ( ( conn->tcp_state & TCP_STATE_ACKED ( TCP_SYN ) ) &&
514
+	     app && app->tcp_op->connected )
515
+		app->tcp_op->connected ( app );
516
+
511
 	return 0;
517
 	return 0;
512
 }
518
 }
513
 
519
 
565
 		conn->tcp_state |= TCP_STATE_ACKED ( acked_flags );
571
 		conn->tcp_state |= TCP_STATE_ACKED ( acked_flags );
566
 
572
 
567
 	/* Notify application of established connection, if applicable */
573
 	/* Notify application of established connection, if applicable */
568
-	if ( ( acked_flags & TCP_SYN ) && app && app->tcp_op->connected )
574
+	if ( ( acked_flags & TCP_SYN ) &&
575
+	     ( conn->tcp_state & TCP_STATE_RCVD ( TCP_SYN ) ) &&
576
+	     app && app->tcp_op->connected )
569
 		app->tcp_op->connected ( app );
577
 		app->tcp_op->connected ( app );
570
 
578
 
571
 	return 0;
579
 	return 0;

Loading…
Cancel
Save