Merge pull request #4 from wllm-rbnt/master

Fix cleanup loop
This commit is contained in:
Alexandre Dulaunoy 2015-04-28 08:24:54 +02:00
commit 2c7500b968

View file

@ -161,6 +161,7 @@ int tcp_destroy_conn(conn)
free_tcp_segment_queue(conn->i2r.oo_queue); free_tcp_segment_queue(conn->i2r.oo_queue);
free_tcp_segment_queue(conn->r2i.oo_queue); free_tcp_segment_queue(conn->r2i.oo_queue);
zero_conn(conn); zero_conn(conn);
free(conn->backptr);
free(conn); free(conn);
return(0); return(0);
@ -175,12 +176,14 @@ int clean_old_conn() {
if(!last_packet_seen_time.tv_sec) if(!last_packet_seen_time.tv_sec)
return 0; // Still processing first block of packets return 0; // Still processing first block of packets
for(conn=first_conn;conn;conn=conn->next) { conn = first_conn;
i++; while(conn) {
tcpconn = &conn->conn; tcpconn = &conn->conn;
conn=conn->next;
timestamp_diff(&last_packet_seen_time, &tcpconn->last_seen_time, &dt); timestamp_diff(&last_packet_seen_time, &tcpconn->last_seen_time, &dt);
if(dt.tv_sec > conn_ttl) { if(dt.tv_sec > conn_ttl) {
tcp_destroy_conn(&(first_conn->conn)); i++;
tcp_destroy_conn(tcpconn);
} }
} }
return i; return i;