From d5dc74824d4a1d115d090f83081e274ec260894f Mon Sep 17 00:00:00 2001 From: William Robinet Date: Mon, 27 Apr 2015 14:37:44 +0200 Subject: [PATCH 1/2] Fix inactive connection removal --- base/tcpconn.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/base/tcpconn.c b/base/tcpconn.c index cb7ebc8..6ea8d86 100644 --- a/base/tcpconn.c +++ b/base/tcpconn.c @@ -161,6 +161,7 @@ int tcp_destroy_conn(conn) free_tcp_segment_queue(conn->i2r.oo_queue); free_tcp_segment_queue(conn->r2i.oo_queue); zero_conn(conn); + free(conn->backptr); free(conn); return(0); @@ -176,11 +177,11 @@ int clean_old_conn() { return 0; // Still processing first block of packets for(conn=first_conn;conn;conn=conn->next) { - i++; tcpconn = &conn->conn; timestamp_diff(&last_packet_seen_time, &tcpconn->last_seen_time, &dt); if(dt.tv_sec > conn_ttl) { - tcp_destroy_conn(&(first_conn->conn)); + i++; + tcp_destroy_conn(tcpconn); } } return i; From d87056ac764ba5d37ebabfe592d798dac67175a1 Mon Sep 17 00:00:00 2001 From: William Robinet Date: Mon, 27 Apr 2015 22:43:47 +0200 Subject: [PATCH 2/2] Avoid auto-vivisection during connection clean-up ... --- base/tcpconn.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/base/tcpconn.c b/base/tcpconn.c index 6ea8d86..f4d9b14 100644 --- a/base/tcpconn.c +++ b/base/tcpconn.c @@ -176,8 +176,10 @@ int clean_old_conn() { if(!last_packet_seen_time.tv_sec) return 0; // Still processing first block of packets - for(conn=first_conn;conn;conn=conn->next) { + conn = first_conn; + while(conn) { tcpconn = &conn->conn; + conn=conn->next; timestamp_diff(&last_packet_seen_time, &tcpconn->last_seen_time, &dt); if(dt.tv_sec > conn_ttl) { i++;