The following commit has been merged in the master branch: commit 1186dbbc15d9c78bf39730b0aed6f6a9dfe23886 Author: Marek Lindner lindner_marek@yahoo.de Date: Mon Jan 15 01:47:18 2007 +0100
merge memory checker from 0.1.x branch into trunk
diff --git a/batman.c b/batman.c index 8fa8ed8..e894640 100644 --- a/batman.c +++ b/batman.c @@ -1009,7 +1009,7 @@ void schedule_own_packet() {
}
-void purge() +void purge( unsigned int curr_time ) { struct list_head *orig_pos, *neigh_pos, *pack_pos, *gw_pos, *gw_pos_tmp, *orig_temp, *neigh_temp, *pack_temp; struct orig_node *orig_node; @@ -1037,7 +1037,7 @@ void purge() pack_node = list_entry(pack_pos, struct pack_node, list);
/* remove them if outdated */ - if ((int)((pack_node->time + TIMEOUT) < get_time())) + if ((int)((pack_node->time + TIMEOUT) < curr_time)) { if (debug_level == 4) { addr_to_string(orig_node->orig, orig_str, ADDR_STR_LEN); @@ -1072,7 +1072,7 @@ void purge() }
/* if no more neighbours (next hops) towards given origin, remove origin */ - if (list_empty(&orig_node->neigh_list) && ((int)(orig_node->last_aware) + TIMEOUT <= ((int)(get_time())))) { + if (list_empty(&orig_node->neigh_list) && ((int)(orig_node->last_aware) + TIMEOUT <= ((int)(curr_time)))) {
if (debug_level == 4) { addr_to_string(orig_node->orig, orig_str, sizeof (orig_str)); @@ -1167,11 +1167,12 @@ void send_vis_packet()
int batman() { - struct list_head *orig_pos, *if_pos, *neigh_pos, *hna_pos; - struct orig_node *orig_node, *orig_neigh_node; + struct list_head *if_pos, *neigh_pos, *hna_pos, *forw_pos, *forw_pos_tmp; + struct orig_node *orig_neigh_node; struct batman_if *batman_if, *if_incoming; struct neigh_node *neigh_node; struct hna_node *hna_node; + struct forw_node *forw_node; unsigned int neigh, hna, netmask, debug_timeout, select_timeout; unsigned char in[1501], *hna_recv_buff; static char orig_str[ADDR_STR_LEN], neigh_str[ADDR_STR_LEN]; @@ -1471,7 +1472,7 @@ int batman() if ( ( routing_class != 0 ) && ( curr_gateway == NULL ) ) choose_gw();
- purge(); + purge( get_time() );
if ( debug_timeout + 1000 < get_time() ) {
@@ -1488,16 +1489,15 @@ int batman() if ( debug_level > 0 ) printf( "Deleting all BATMAN routes\n" );
- list_for_each(orig_pos, &orig_list) { + purge( get_time() + TIMEOUT + orginator_interval );
- orig_node = list_entry(orig_pos, struct orig_node, list); + list_for_each_safe( forw_pos, forw_pos_tmp, &forw_list ) { + forw_node = list_entry( forw_pos, struct forw_node, list );
- /* remove old announced network(s) */ - if ( orig_node->hna_buff_len > 0 ) - add_del_hna( orig_node, 1 ); + list_del( forw_pos );
- if ( orig_node->router != 0 ) - add_del_route( orig_node->orig, 32, orig_node->router, 1, orig_node->batman_if->dev, batman_if->udp_send_sock ); + debugFree( forw_node->pack_buff, 112 ); + debugFree( forw_node, 113 );
}
@@ -1512,8 +1512,6 @@ int batman() set_rp_filter( if_rp_filter_default_old, "default" );
- checkLeak(); - return 0;
} diff --git a/batman.h b/batman.h index 9d16b59..7307705 100644 --- a/batman.h +++ b/batman.h @@ -24,6 +24,7 @@ #include <pthread.h> #include "list.h"
+ #define SOURCE_VERSION "0.2 early alpha" #define COMPAT_VERSION 2 #define PORT 1966 diff --git a/posix.c b/posix.c index 27971e5..4dad4ec 100644 --- a/posix.c +++ b/posix.c @@ -484,10 +484,10 @@ int add_default_route() {
void close_all_sockets() {
- struct list_head *if_pos; + struct list_head *if_pos, *if_pos_tmp; struct batman_if *batman_if;
- list_for_each(if_pos, &if_list) { + list_for_each_safe(if_pos, if_pos_tmp, &if_list) {
batman_if = list_entry(if_pos, struct batman_if, list);
@@ -501,6 +501,9 @@ void close_all_sockets() { close(batman_if->udp_recv_sock); close(batman_if->udp_send_sock);
+ list_del( if_pos ); + debugFree( if_pos, 203 ); + }
if ( ( routing_class != 0 ) && ( curr_gateway != NULL ) ) @@ -1325,6 +1328,8 @@ int main(int argc, char *argv[])
close_all_sockets();
+ checkLeak(); + return res;
}