CFG_UNREF is moved outside of the lock in cfg_install_global function
authorMiklos Tirpak <miklos@iptel.org>
Fri, 15 Feb 2008 09:13:39 +0000 (09:13 +0000)
committerMiklos Tirpak <miklos@iptel.org>
Fri, 15 Feb 2008 09:13:39 +0000 (09:13 +0000)
(shm_free()s might take longer)
Patch from Andrei

cfg/cfg_struct.c

index 1eca977..9383b96 100644 (file)
@@ -524,19 +524,24 @@ void cfg_install_child_cb(cfg_child_cb_t *cb_first, cfg_child_cb_t *cb_last)
 void cfg_install_global(cfg_block_t *block, char **replaced,
                        cfg_child_cb_t *cb_first, cfg_child_cb_t *cb_last)
 {
+       cfg_block_t* old_cfg;
+       
+       CFG_REF(block);
+
        CFG_LOCK();
 
-       if (*cfg_global) {
-               if (replaced) (*cfg_global)->replaced = replaced;
-               CFG_UNREF(*cfg_global);
-       }
-       CFG_REF(block);
+       old_cfg = *cfg_global;
        *cfg_global = block;
 
        if (cb_first)
                cfg_install_child_cb(cb_first, cb_last);
 
        CFG_UNLOCK();
+       
+       if (old_cfg) {
+               if (replaced) (old_cfg)->replaced = replaced;
+               CFG_UNREF(old_cfg);
+       }
 
 }