浏览代码

- fix: blacklist destroy not freeing all the shmem on exit and missing
initializations (thanks to Vladimir Marek <[email protected]>)

Andrei Pelinescu-Onciul 18 年之前
父节点
当前提交
63d963ee7f
共有 1 个文件被更改,包括 16 次插入0 次删除
  1. 16 0
      dst_blacklist.c

+ 16 - 0
dst_blacklist.c

@@ -123,6 +123,11 @@ inline static unsigned short dst_blst_hash_no(unsigned char proto,
 
 void destroy_dst_blacklist()
 {
+	int r;
+	struct dst_blst_entry** crt;
+	struct dst_blst_entry** tmp;
+	struct dst_blst_entry* e;
+	
 	if (blst_timer_h){
 		timer_del(blst_timer_h);
 		timer_free(blst_timer_h);
@@ -134,6 +139,14 @@ void destroy_dst_blacklist()
 		blst_lock=0;
 	}
 	if (dst_blst_hash){
+		for(r=0; r<DST_BLST_HASH_SIZE; r++){
+			for (crt=&dst_blst_hash[r], tmp=&(*crt)->next; *crt; 
+					crt=tmp, tmp=&(*crt)->next){
+			e=*crt;
+			*crt=(*crt)->next;
+			blst_destroy_entry(e);
+			}
+		}
 		shm_free(dst_blst_hash);
 		dst_blst_hash=0;
 	}
@@ -155,12 +168,15 @@ int init_dst_blacklist()
 		ret=E_OUT_OF_MEM;
 		goto error;
 	}
+	*blst_mem_used=0;
 	dst_blst_hash=shm_malloc(sizeof(struct dst_blst_entry*) *
 											DST_BLST_HASH_SIZE);
 	if (dst_blst_hash==0){
 		ret=E_OUT_OF_MEM;
 		goto error;
 	}
+	memset(dst_blst_hash, 0, sizeof(struct dst_blst_entry*) *
+								DST_BLST_HASH_SIZE);
 	blst_lock=lock_alloc();
 	if (blst_lock==0){
 		ret=E_OUT_OF_MEM;