Browse code

- non forking init_child (PROC_INIT) fix (closes SER-287)

Andrei Pelinescu-Onciul authored on 19/06/2007 14:37:54
Showing 1 changed files
... ...
@@ -915,6 +915,19 @@ int main_loop()
915 915
 		   as new processes are forked (while skipping 0 reserved for main
916 916
 		*/
917 917
 
918
+		/* init childs with rank==PROC_INIT before forking any process, 
919
+		 * this is a place for delayed (after mod_init) initializations
920
+		 * (e.g. shared vars that depend on the total number of processes
921
+		 * that is known only after all mod_inits have been executed )
922
+		 * WARNING: the same init_child will be called latter, a second time
923
+		 * for the "main" process with rank PROC_MAIN (make sure things are 
924
+		 * not initialized twice)*/
925
+		if (init_child(PROC_INIT) < 0) {
926
+			LOG(L_ERR, "ERROR: main_dontfork: init_child(PROC_INT) --"
927
+						" exiting\n");
928
+			goto error;
929
+		}
930
+
918 931
 #ifdef USE_SLOW_TIMER
919 932
 		/* we need another process to act as the "slow" timer*/
920 933
 				pid = fork_process(PROC_TIMER, "slow timer", 0);
... ...
@@ -958,19 +971,6 @@ int main_loop()
958 958
 		snprintf(pt[process_no].desc, MAX_PT_DESC,
959 959
 			"stand-alone receiver @ %s:%s",
960 960
 			 bind_address->name.s, bind_address->port_no_str.s );
961
-
962
-		/* init childs with rank==PROC_INIT before forking any process, 
963
-		 * this is a place for delayed (after mod_init) initializations
964
-		 * (e.g. shared vars that depend on the total number of processes
965
-		 * that is known only after all mod_inits have been executed )
966
-		 * WARNING: the same init_child will be called latter, a second time
967
-		 * for the "main" process with rank PROC_MAIN (make sure things are 
968
-		 * not initialized twice)*/
969
-		if (init_child(PROC_INIT) < 0) {
970
-			LOG(L_ERR, "ERROR: main_dontfork: init_child(PROC_INT) --"
971
-						" exiting\n");
972
-			goto error;
973
-		}
974 961
 	
975 962
 	/* call it also w/ PROC_MAIN to make sure modules that init things only
976 963
 	 * in PROC_MAIN get a chance to run */