Browse code

- now destroy_modules & shm. mem. are called only once, from the "main" process ( added is_main to main.c)

Andrei Pelinescu-Onciul authored on 06/12/2001 21:10:29
Showing 1 changed files
... ...
@@ -165,6 +165,7 @@ extern FILE* yyin;
165 165
 extern int yyparse();
166 166
 
167 167
 
168
+static int is_main=0; /* flag = is this the  "main" process? */
168 169
 
169 170
 /* daemon init, return 0 on success, -1 on error */
170 171
 int daemonize(char*  name)
... ...
@@ -247,7 +248,8 @@ int main_loop()
247 248
 					}
248 249
 				}
249 250
 		}
250
-		/* receive loop */
251
+		/* main process, receive loop */
252
+		is_main=1;
251 253
 		udp_rcv_loop();
252 254
 	}else{
253 255
 		for(r=0;r<addresses_no;r++){
... ...
@@ -269,6 +271,8 @@ int main_loop()
269 271
 			close(udp_sock); /*parent*/
270 272
 		}
271 273
 	}
274
+	/*this is the main process*/
275
+	is_main=1;
272 276
 	if (timer_list){
273 277
 		for(;;){
274 278
 			/* debug:  instead of doing something usefull */
... ...
@@ -308,15 +312,18 @@ static void sig_usr(int signo)
308 312
 		DPrint("INT received, program terminates\n");
309 313
 		DPrint("Thank you for flying ser\n");
310 314
 		/* WARNING: very dangerous, might be unsafe*/
311
-		destroy_modules();
315
+		if (is_main)
316
+			destroy_modules();
312 317
 #ifdef PKG_MALLOC
313 318
 		pkg_status();
314 319
 #endif
315 320
 #ifdef SHM_MEM
316
-		shm_status();
321
+		if (is_main)
322
+			shm_status();
317 323
 #endif
318 324
 #ifdef SHM_MEM
319
-		shm_mem_destroy();
325
+		if (is_main)
326
+			shm_mem_destroy();
320 327
 #endif
321 328
 		exit(0);
322 329
 	} else if (signo==SIGUSR1) { /* statistic */