Browse code

- fix: blacklist destroy not freeing all the shmem on exit and missing initializations (thanks to Vladimir Marek <vlada@iptel.org>)

Andrei Pelinescu-Onciul authored on 03/05/2007 18:38:23
Showing 1 changed files
... ...
@@ -123,6 +123,11 @@ inline static unsigned short dst_blst_hash_no(unsigned char proto,
123 123
 
124 124
 void destroy_dst_blacklist()
125 125
 {
126
+	int r;
127
+	struct dst_blst_entry** crt;
128
+	struct dst_blst_entry** tmp;
129
+	struct dst_blst_entry* e;
130
+	
126 131
 	if (blst_timer_h){
127 132
 		timer_del(blst_timer_h);
128 133
 		timer_free(blst_timer_h);
... ...
@@ -134,6 +139,14 @@ void destroy_dst_blacklist()
134 139
 		blst_lock=0;
135 140
 	}
136 141
 	if (dst_blst_hash){
142
+		for(r=0; r<DST_BLST_HASH_SIZE; r++){
143
+			for (crt=&dst_blst_hash[r], tmp=&(*crt)->next; *crt; 
144
+					crt=tmp, tmp=&(*crt)->next){
145
+			e=*crt;
146
+			*crt=(*crt)->next;
147
+			blst_destroy_entry(e);
148
+			}
149
+		}
137 150
 		shm_free(dst_blst_hash);
138 151
 		dst_blst_hash=0;
139 152
 	}
... ...
@@ -155,12 +168,15 @@ int init_dst_blacklist()
155 168
 		ret=E_OUT_OF_MEM;
156 169
 		goto error;
157 170
 	}
171
+	*blst_mem_used=0;
158 172
 	dst_blst_hash=shm_malloc(sizeof(struct dst_blst_entry*) *
159 173
 											DST_BLST_HASH_SIZE);
160 174
 	if (dst_blst_hash==0){
161 175
 		ret=E_OUT_OF_MEM;
162 176
 		goto error;
163 177
 	}
178
+	memset(dst_blst_hash, 0, sizeof(struct dst_blst_entry*) *
179
+								DST_BLST_HASH_SIZE);
164 180
 	blst_lock=lock_alloc();
165 181
 	if (blst_lock==0){
166 182
 		ret=E_OUT_OF_MEM;