Module: sip-router
Branch: andrei/raw_sock
Commit: fbf0d2e03c019e51281ce569b93843ab0577cc0f
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=fbf0d2e…
Author: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei(a)iptel.org>
Date: Tue Aug 10 11:20:26 2010 +0200
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).
---
main.c | 22 +++++++++++++++++-----
1 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/main.c b/main.c
index d157a6b..9b594a0 100644
--- a/main.c
+++ b/main.c
@@ -1285,6 +1285,15 @@ int main_loop()
" (no fork)\n");
}
+ /* delay cfg_shmize to the last moment (it must be called _before_
+ forking). Changes to default cfgs after this point will be
+ ignored.
+ */
+ if (cfg_shmize() < 0) {
+ LOG(L_CRIT, "could not initialize shared configuration\n");
+ goto error;
+ }
+
/* Register the children that will keep updating their
* local configuration */
cfg_register_child(
@@ -1503,6 +1512,14 @@ int main_loop()
* sending) so we open all first*/
if (do_suid()==-1) goto error; /* try to drop privileges */
+ /* delay cfg_shmize to the last moment (it must be called _before_
+ forking). Changes to default cfgs after this point will be
+ ignored (cfg_shmize() will copy the default cfgs into shmem).
+ */
+ if (cfg_shmize() < 0) {
+ LOG(L_CRIT, "could not initialize shared configuration\n");
+ goto error;
+ }
/* init childs with rank==PROC_INIT before forking any process,
* this is a place for delayed (after mod_init) initializations
* (e.g. shared vars that depend on the total number of processes
@@ -2328,11 +2345,6 @@ try_select_again: tval.tv_usec = 0;
goto error;
}
- if (cfg_shmize() < 0) {
- LOG(L_CRIT, "could not initialize shared configuration\n");
- goto error;
- }
-
/* initialize process_table, add core process no. (calc_proc_no()) to the
* processes registered from the modules*/
if (init_pt(calc_proc_no())==-1)