From f20a809de33d0fd495753b3468e0a8f6dd7f44f9 Mon Sep 17 00:00:00 2001 From: Miklos Tirpak Date: Tue, 11 Dec 2007 16:15:55 +0000 Subject: [PATCH] - Updating the local configuration in the child processes that are forked by modules. - Per-child process config destroy function is introduced: should be called when a child process exists, but SER continues running, not needed to be called otherwise. --- cfg/cfg_struct.c | 35 +++++++++++++++++++++++++++++++++++ cfg/cfg_struct.h | 10 ++++++++++ 2 files changed, 45 insertions(+) diff --git a/cfg/cfg_struct.c b/cfg/cfg_struct.c index b3596fa941..dee9ee2c84 100644 --- a/cfg/cfg_struct.c +++ b/cfg/cfg_struct.c @@ -302,6 +302,41 @@ int cfg_child_init(void) return 0; } +/* per-child process destroy function + * Should be called only when the child process exits, + * but SER continues running + * + * WARNING: this function call must be the very last action + * before the child process exits, because the local config + * is not available afterwards. + */ +void cfg_child_destroy(void) +{ + /* unref the local config */ + if (cfg_local) { + CFG_UNREF(cfg_local); + cfg_local = NULL; + } + + /* unref the per-process callback list */ + if (atomic_dec_and_test(&cfg_child_cb->refcnt)) { + /* No more pocess refers to this callback. + Did this process block the deletion, + or is there any other process that has not + reached prev_cb yet? */ + CFG_LOCK(); + if (*cfg_child_cb_first == cfg_child_cb) { + /* yes, this process was blocking the deletion */ + *cfg_child_cb_first = cfg_child_cb->next; + CFG_UNLOCK(); + shm_free(cfg_child_cb); + } else { + CFG_UNLOCK(); + } + } + cfg_child_cb = NULL; +} + /* searches a variable definition by group and variable name */ int cfg_lookup_var(str *gname, str *vname, cfg_group_t **group, cfg_mapping_t **var) diff --git a/cfg/cfg_struct.h b/cfg/cfg_struct.h index e9554adc79..e1948540c2 100644 --- a/cfg/cfg_struct.h +++ b/cfg/cfg_struct.h @@ -123,6 +123,16 @@ void cfg_destroy(void); /* per-child process init function */ int cfg_child_init(void); +/* per-child process destroy function + * Should be called only when the child process exits, + * but SER continues running. + * + * WARNING: this function call must be the very last action + * before the child process exits, because the local config + * is not available afterwards. + */ +void cfg_child_destroy(void); + /* creates a new cfg group, and adds it to the linked list */ int cfg_new_group(char *name, int num, cfg_mapping_t *mapping, char *vars, int size, void **handle); -- 2.20.1