Browse code

cfg: delay cfg_shmize to just before forking

cfg_shmize() delayed to allow late changes in the default config
(any changes in the default config after cfg_shmize() are ignored).

Andrei Pelinescu-Onciul authored on 10/08/2010 09:20:26
Showing 1 changed files
... ...
@@ -1285,6 +1285,15 @@ int main_loop()
1285 1285
 						" (no fork)\n");
1286 1286
 		}
1287 1287
 
1288
+		/* delay cfg_shmize to the last moment (it must be called _before_
1289
+		   forking). Changes to default cfgs after this point will be
1290
+		   ignored.
1291
+		*/
1292
+		if (cfg_shmize() < 0) {
1293
+			LOG(L_CRIT, "could not initialize shared configuration\n");
1294
+			goto error;
1295
+		}
1296
+	
1288 1297
 		/* Register the children that will keep updating their
1289 1298
 		 * local configuration */
1290 1299
 		cfg_register_child(
... ...
@@ -1503,6 +1512,14 @@ int main_loop()
1503 1503
 			 * sending) so we open all first*/
1504 1504
 		if (do_suid()==-1) goto error; /* try to drop privileges */
1505 1505
 
1506
+		/* delay cfg_shmize to the last moment (it must be called _before_
1507
+		   forking). Changes to default cfgs after this point will be
1508
+		   ignored (cfg_shmize() will copy the default cfgs into shmem).
1509
+		*/
1510
+		if (cfg_shmize() < 0) {
1511
+			LOG(L_CRIT, "could not initialize shared configuration\n");
1512
+			goto error;
1513
+		}
1506 1514
 		/* init childs with rank==PROC_INIT before forking any process,
1507 1515
 		 * this is a place for delayed (after mod_init) initializations
1508 1516
 		 * (e.g. shared vars that depend on the total number of processes
... ...
@@ -2328,11 +2345,6 @@ try_select_again:	tval.tv_usec = 0;
2328 2328
 		goto error;
2329 2329
 	}
2330 2330
 	
2331
-	if (cfg_shmize() < 0) {
2332
-		LOG(L_CRIT, "could not initialize shared configuration\n");
2333
-		goto error;
2334
-	}
2335
-	
2336 2331
 	/* initialize process_table, add core process no. (calc_proc_no()) to the
2337 2332
 	 * processes registered from the modules*/
2338 2333
 	if (init_pt(calc_proc_no())==-1)