Explorar el Código

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 <[email protected]>
Reported-and-tested-by: Jan Pewner <[email protected]>
Andrei Pelinescu-Onciul hace 16 años
padre
commit
299ca7ce74
Se han modificado 1 ficheros con 7 adiciones y 2 borrados
  1. 7 2
      tcp_main.c

+ 7 - 2
tcp_main.c

@@ -3699,12 +3699,19 @@ static ticks_t tcpconn_main_timeout(ticks_t t, struct timer_ln* tl, void* data)
 			TCP_EV_SEND_TIMEOUT(0, &c->rcv);
 			TCP_EV_SEND_TIMEOUT(0, &c->rcv);
 			TCP_STATS_SEND_TIMEOUT();
 			TCP_STATS_SEND_TIMEOUT();
 		}
 		}
+	}else{
+		/* idle timeout */
+		TCP_EV_IDLE_CONN_CLOSED(0, &c->rcv);
+		TCP_STATS_CON_TIMEOUT();
 	}
 	}
 #else /* ! TCP_ASYNC */
 #else /* ! TCP_ASYNC */
 	if (TICKS_LT(t, c->timeout)){
 	if (TICKS_LT(t, c->timeout)){
 		/* timeout extended, exit */
 		/* timeout extended, exit */
 		return (ticks_t)(c->timeout - t);
 		return (ticks_t)(c->timeout - t);
 	}
 	}
+	/* idle timeout */
+	TCP_EV_IDLE_CONN_CLOSED(0, &c->rcv);
+	TCP_STATS_CON_TIMEOUT();
 #endif /* TCP_ASYNC */
 #endif /* TCP_ASYNC */
 	DBG("tcp_main: timeout for %p\n", c);
 	DBG("tcp_main: timeout for %p\n", c);
 	if (likely(c->flags & F_CONN_HASHED)){
 	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)
 			c->flags&=~(F_CONN_READ_W|F_CONN_WRITE_W);
 			c->flags&=~(F_CONN_READ_W|F_CONN_WRITE_W);
 		}
 		}
 	}
 	}
-	TCP_EV_IDLE_CONN_CLOSED(0, &c->rcv);
-	TCP_STATS_CON_TIMEOUT();
 	tcpconn_put_destroy(c);
 	tcpconn_put_destroy(c);
 	return 0;
 	return 0;
 }
 }