Module: sip-router Branch: master Commit: 517df28fc695b047d1f7f3cd4376a5f9240b7906 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=517df28f...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Sun Jan 2 19:39:11 2011 +0100
mtree: skip db init for special ranks
---
modules/mtree/mtree_mod.c | 24 +++++++++++++++--------- 1 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/modules/mtree/mtree_mod.c b/modules/mtree/mtree_mod.c index aeb98ad..29ea12a 100644 --- a/modules/mtree/mtree_mod.c +++ b/modules/mtree/mtree_mod.c @@ -104,8 +104,8 @@ static int w_mt_match(struct sip_msg* msg, char* str1, char* str2,
static int mod_init(void); static void mod_destroy(void); -static int child_init(void); -static int mod_child_init(int r); +static int child_init(int rank); +static int mi_child_init(void);
static int mt_match(struct sip_msg *msg, gparam_t *dm, gparam_t *var, gparam_t *mode); @@ -142,7 +142,7 @@ static param_export_t params[]={ };
static mi_export_t mi_cmds[] = { - { "mt_reload", mt_mi_reload, 0, 0, child_init }, + { "mt_reload", mt_mi_reload, 0, 0, mi_child_init }, { "mt_list", mt_mi_list, 0, 0, 0 }, { "mt_summary", mt_mi_summary, 0, 0, 0 }, { 0, 0, 0, 0, 0} @@ -161,7 +161,7 @@ struct module_exports exports = { mod_init, /* module initialization function */ 0, /* response function */ mod_destroy, /* destroy function */ - mod_child_init /* per child init function */ + child_init /* per child init function */ };
@@ -322,8 +322,10 @@ error1: return -1; }
- -static int child_init(void) +/** + * mi and worker process initialization + */ +static int mi_child_init(void) { if(db_con!=NULL) return 0; @@ -339,12 +341,16 @@ static int child_init(void)
/* each child get a new connection to the database */ -static int mod_child_init(int r) +static int child_init(int rank) { - if ( child_init()!=0 ) + /* skip child init for non-worker process ranks */ + if (rank==PROC_INIT || rank==PROC_MAIN || rank==PROC_TCP_MAIN) + return 0; + + if ( mi_child_init()!=0 ) return -1;
- LM_DBG("#%d: database connection opened successfully\n",r); + LM_DBG("#%d: database connection opened successfully\n", rank);
return 0; }