Module: sip-router
Branch: master
Commit: a367a923f83a60b1b72907d42afff4484f49ad35
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a367a92…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Fri Sep 30 13:58:16 2011 +0200
lib/kmi, mi_*: better handling of mi child init
---
lib/kmi/mi.c | 21 +++++++++++++++------
lib/kmi/mi.h | 2 +-
modules/mi_rpc/mi_rpc_mod.c | 2 +-
modules_k/mi_datagram/mi_datagram.c | 2 +-
modules_k/mi_fifo/mi_fifo.c | 2 +-
modules_k/mi_xmlrpc/mi_xmlrpc.c | 2 +-
6 files changed, 20 insertions(+), 11 deletions(-)
diff --git a/lib/kmi/mi.c b/lib/kmi/mi.c
index 662de88..b20de19 100644
--- a/lib/kmi/mi.c
+++ b/lib/kmi/mi.c
@@ -100,7 +100,14 @@ int register_mi_mod( char *mod_name, mi_export_t *mis)
static int mi_commands_initialized = 0;
-int init_mi_child(void)
+
+/**
+ * Init a process to work properly for MI commands
+ * - rank: rank of the process (PROC_XYZ...)
+ * - mode: 0 - don't try to init worker for SIP commands
+ * 1 - try to init worker for SIP commands
+ */
+int init_mi_child(int rank, int mode)
{
int i;
@@ -114,11 +121,13 @@ int init_mi_child(void)
return -1;
}
}
- if(is_sip_worker(PROC_NOCHLDINIT)) {
- LM_DBG("initalizing proc rpc for sip handling\n");
- if(init_child(PROC_SIPRPC)<0) {
- LM_ERR("failed to init proc rpc for sip handling\n");
- return -1;
+ if(mode==1) {
+ if(is_sip_worker(rank)) {
+ LM_DBG("initalizing proc rpc for sip handling\n");
+ if(init_child(PROC_SIPRPC)<0) {
+ LM_ERR("failed to init proc rpc for sip handling\n");
+ return -1;
+ }
}
}
return 0;
diff --git a/lib/kmi/mi.h b/lib/kmi/mi.h
index 988bcd1..6735930 100644
--- a/lib/kmi/mi.h
+++ b/lib/kmi/mi.h
@@ -68,7 +68,7 @@ int register_mi_cmd( mi_cmd_f f, char *name, void *param,
int register_mi_mod( char *mod_name, mi_export_t *mis);
-int init_mi_child(void);
+int init_mi_child(int rank, int mode);
struct mi_cmd* lookup_mi_cmd( char *name, int len);
diff --git a/modules/mi_rpc/mi_rpc_mod.c b/modules/mi_rpc/mi_rpc_mod.c
index bfc4aaf..20acb9e 100644
--- a/modules/mi_rpc/mi_rpc_mod.c
+++ b/modules/mi_rpc/mi_rpc_mod.c
@@ -80,7 +80,7 @@ static int child_init(int rank)
{
if(is_rpc_worker(rank)) {
LM_DBG("initializing child[%d] for rpc handling\n", rank);
- if(init_mi_child()!=0) {
+ if(init_mi_child(rank, 0)!=0) {
LM_CRIT("Failed to init the mi commands\n");
return -1;
}
diff --git a/modules_k/mi_datagram/mi_datagram.c b/modules_k/mi_datagram/mi_datagram.c
index d36af3e..c0fd990 100644
--- a/modules_k/mi_datagram/mi_datagram.c
+++ b/modules_k/mi_datagram/mi_datagram.c
@@ -329,7 +329,7 @@ static void datagram_process(int rank)
LM_INFO("a new child %d/%d\n", rank, getpid());
/*child's initial settings*/
- if ( init_mi_child()!=0) {
+ if ( init_mi_child(PROC_NOCHLDINIT, 1)!=0) {
LM_CRIT("failed to init the mi process\n");
exit(-1);
}
diff --git a/modules_k/mi_fifo/mi_fifo.c b/modules_k/mi_fifo/mi_fifo.c
index 6598e34..88666c8 100644
--- a/modules_k/mi_fifo/mi_fifo.c
+++ b/modules_k/mi_fifo/mi_fifo.c
@@ -229,7 +229,7 @@ static void fifo_process(int rank)
exit(-1);
}
- if( init_mi_child()!=0) {
+ if( init_mi_child(PROC_NOCHLDINIT, 1)!=0) {
LM_CRIT("Failed to init the mi process\n");
exit(-1);
}
diff --git a/modules_k/mi_xmlrpc/mi_xmlrpc.c b/modules_k/mi_xmlrpc/mi_xmlrpc.c
index 9be1650..784f07e 100644
--- a/modules_k/mi_xmlrpc/mi_xmlrpc.c
+++ b/modules_k/mi_xmlrpc/mi_xmlrpc.c
@@ -231,7 +231,7 @@ static void xmlrpc_process(int rank)
ServerInit(&srv);
- if( init_mi_child() != 0 ) {
+ if( init_mi_child(PROC_NOCHLDINIT, 1) != 0 ) {
LM_CRIT("failed to init the mi process\n");
goto error;
}