Browse code

tcp: minor fix: TCP_EV_IDLE_CONN_CLOSED

TCP_EV_IDLE_CONN_CLOSED was called also on connect and send timeout (along
with TCP_EV_CONNECT_TIMEOUT and TCP_EV_SEND_TIMEOUT). Same for the
corresponding statistics.

Reported-and-tested-by: Libor Chocholaty <libor@iptel.org>
Reported-and-tested-by: Jan Pewner <jpewner@iptel.org>

Andrei Pelinescu-Onciul authored on 26/05/2009 15:41:30
Showing 1 changed files
... ...
@@ -3699,12 +3699,19 @@ static ticks_t tcpconn_main_timeout(ticks_t t, struct timer_ln* tl, void* data)
3699 3699
 			TCP_EV_SEND_TIMEOUT(0, &c->rcv);
3700 3700
 			TCP_STATS_SEND_TIMEOUT();
3701 3701
 		}
3702
+	}else{
3703
+		/* idle timeout */
3704
+		TCP_EV_IDLE_CONN_CLOSED(0, &c->rcv);
3705
+		TCP_STATS_CON_TIMEOUT();
3702 3706
 	}
3703 3707
 #else /* ! TCP_ASYNC */
3704 3708
 	if (TICKS_LT(t, c->timeout)){
3705 3709
 		/* timeout extended, exit */
3706 3710
 		return (ticks_t)(c->timeout - t);
3707 3711
 	}
3712
+	/* idle timeout */
3713
+	TCP_EV_IDLE_CONN_CLOSED(0, &c->rcv);
3714
+	TCP_STATS_CON_TIMEOUT();
3708 3715
 #endif /* TCP_ASYNC */
3709 3716
 	DBG("tcp_main: timeout for %p\n", c);
3710 3717
 	if (likely(c->flags & F_CONN_HASHED)){
... ...
@@ -3726,8 +3733,6 @@ static ticks_t tcpconn_main_timeout(ticks_t t, struct timer_ln* tl, void* data)
3726 3733
 			c->flags&=~(F_CONN_READ_W|F_CONN_WRITE_W);
3727 3734
 		}
3728 3735
 	}
3729
-	TCP_EV_IDLE_CONN_CLOSED(0, &c->rcv);
3730
-	TCP_STATS_CON_TIMEOUT();
3731 3736
 	tcpconn_put_destroy(c);
3732 3737
 	return 0;
3733 3738
 }