Module: sip-router
Branch: ser_core_cvs
Commit: c0f12714391fa6b359cceaed22ed238ba5387457
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c0f12714391fa6b359cceaed22ed238ba5387457

Author: Miklos Tirpak <[email protected]>
Committer: Miklos Tirpak <[email protected]>
Date:   Mon Jul 13 15:13:12 2009 +0000

cfg framework: fix the group handles in the main process
(backport from GIT)

    The main process does not have a local configuration,
    it has access only to the config values that were set before
    forking. As a result, the group handles cannot ponint to
    the shared memory address because the shared memory block
    may be freed later by one of the child processes. This problem
    resulted sometimes in a core dump after the processes were killed
    when the main process tried to access a variable from shared mem
    which was no longer available.

---

 cfg/cfg_script.c |    1 -
 cfg/cfg_struct.c |   12 +++++++-----
 2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/cfg/cfg_script.c b/cfg/cfg_script.c
index 39a4068..8804e40 100644
--- a/cfg/cfg_script.c
+++ b/cfg/cfg_script.c
@@ -143,7 +143,6 @@ error:
 /* fix-up the dynamically declared group:
  *  - allocate memory for the arrays
  *  - set the values within the memory block
- *  - notify the drivers about the new group
  */
 int cfg_script_fixup(cfg_group_t *group, unsigned char *block)
 {
diff --git a/cfg/cfg_struct.c b/cfg/cfg_struct.c
index fe7d8d6..966443e 100644
--- a/cfg/cfg_struct.c
+++ b/cfg/cfg_struct.c
@@ -194,21 +194,23 @@ int cfg_shmize(void)
                        /* clone the strings to shm mem */
                        if (cfg_shmize_strings(group)) goto error;
 
-                       /* copy the values to the new block,
-                       and update the module's handle */
+                       /* copy the values to the new block */
                        memcpy(block->vars+group->offset, group->vars, 
group->size);
-                       *(group->handle) = block->vars+group->offset;
                } else {
                        /* The group was declared with NULL values,
                         * we have to fix it up.
                         * The fixup function takes care about the values,
                         * it fills up the block */
                        if (cfg_script_fixup(group, block->vars+group->offset)) 
goto error;
-                       *(group->handle) = block->vars+group->offset;
 
-                       /* notify the drivers about the new config definition */
+                       /* Notify the drivers about the new config definition.
+                        * Temporary set the group handle so that the drivers 
have a chance to
+                        * overwrite the default values. The handle must be 
reset after this
+                        * because the main process does not have a local 
configuration. */
+                       *(group->handle) = block->vars+group->offset;
                        cfg_notify_drivers(group->name, group->name_len,
                                        group->mapping->def);
+                       *(group->handle) = NULL;
                }
        }
        /* try to fixup the selects that failed to be fixed-up previously */


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to