Author: tjansen Date: Mon Oct 5 16:17:57 2009 New Revision: 1015 Log: Free ARP cache during shutdown. Modified: trunk/include/arp.h trunk/libpisa/arp.c trunk/pisacd/cdmain.c trunk/pisasd/sdmain.c Modified: trunk/include/arp.h ============================================================================== --- trunk/include/arp.h Mon Oct 5 14:52:21 2009 (r1014) +++ trunk/include/arp.h Mon Oct 5 16:17:57 2009 (r1015) @@ -25,4 +25,6 @@ void pisa_mac_write_string(pisa_mac *mac, char *string); int pisa_arp_from_ipv4(struct in_addr *ip, pisa_mac *mac); +void pisa_arp_cleanup(void); + #endif /* PISA_ARP_H */ Modified: trunk/libpisa/arp.c ============================================================================== --- trunk/libpisa/arp.c Mon Oct 5 14:52:21 2009 (r1014) +++ trunk/libpisa/arp.c Mon Oct 5 16:17:57 2009 (r1015) @@ -148,3 +148,17 @@ return -1; } + +/** + * Clean up the ARP cache and free the allocated memory. + */ +void pisa_arp_cleanup(void) +{ + struct pisa_arp_cache_entry *e = arp_cache; + + while (e) { + HASH_DEL(arp_cache, e); + free(e); + e = arp_cache; + } +} Modified: trunk/pisacd/cdmain.c ============================================================================== --- trunk/pisacd/cdmain.c Mon Oct 5 14:52:21 2009 (r1014) +++ trunk/pisacd/cdmain.c Mon Oct 5 16:17:57 2009 (r1015) @@ -263,6 +263,7 @@ pisa_nat_destroy(cd_ctx.natlist); cdctx_destroy(&cd_ctx); cdconf_destroy(&cd_cfg); + pisa_arp_cleanup(); close(cd_ctx.fd_pacli); close(cd_ctx.fd_pasrv); Modified: trunk/pisasd/sdmain.c ============================================================================== --- trunk/pisasd/sdmain.c Mon Oct 5 14:52:21 2009 (r1014) +++ trunk/pisasd/sdmain.c Mon Oct 5 16:17:57 2009 (r1015) @@ -308,6 +308,7 @@ } sdctx_destroy(&sd_ctx); sdconf_destroy(&sd_cfg); + pisa_arp_cleanup(); /* finish all the remaining jobs */ close(sd_ctx.tunc);