[sr-dev] git:master: core: allow to specify that rpc worker may handle sip commands

Daniel-Constantin Mierla miconda at gmail.com
Thu Sep 29 10:26:57 CEST 2011


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

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date:   Wed Sep 28 23:52:49 2011 +0200

core: allow to specify that rpc worker may handle sip commands

- a sip child process can handle rpc (e.g., xmlops module) and a rpc
  child process can handle sip commands (e.g., mi cmd to end dlg and
  event_route[tm:local-request])

---

 sr_module.c |   26 ++++++++++++++++++++------
 sr_module.h |    5 +++--
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/sr_module.c b/sr_module.c
index 9da476f..564900c 100644
--- a/sr_module.c
+++ b/sr_module.c
@@ -113,23 +113,37 @@ int mod_response_cbk_no=0;
 response_function* mod_response_cbks=0;
 
 /**
- * if set to 1, SIP worker processes handle RPC commands as well
+ * if bit 1 set, SIP worker processes handle RPC commands as well
+ * if bit 2 set, RPC worker processes handle SIP commands as well
  */
 static int child_sip_rpc_mode = 0;
 
-void set_sip_rpc_mode(int mode)
+#define CHILD_SIP_RPC	1<<0
+#define CHILD_RPC_SIP	1<<1
+
+void set_child_sip_rpc_mode(void)
 {
-	child_sip_rpc_mode = mode;
+	child_sip_rpc_mode |= CHILD_SIP_RPC;
 }
 
-int get_sip_rpc_mode(void)
+void set_child_rpc_sip_mode(void)
 {
-	return child_sip_rpc_mode;
+	child_sip_rpc_mode |= CHILD_RPC_SIP;
 }
 
 int is_rpc_worker(int rank)
 {
-	if(rank==PROC_RPC || (rank>PROC_MAIN && child_sip_rpc_mode!=0))
+	if(rank==PROC_RPC
+			|| (rank>PROC_MAIN && (child_sip_rpc_mode&CHILD_SIP_RPC)!=0))
+		return 1;
+	return 0;
+}
+
+int is_sip_worker(int rank)
+{
+	if(rank>PROC_MAIN
+			|| ((rank==PROC_RPC || rank==PROC_NOCHLDINIT)
+					&& (child_sip_rpc_mode&CHILD_RPC_SIP)!=0))
 		return 1;
 	return 0;
 }
diff --git a/sr_module.h b/sr_module.h
index 5a56923..71ffa92 100644
--- a/sr_module.h
+++ b/sr_module.h
@@ -655,8 +655,9 @@ int fixup_free_fparam_2(void** param, int param_no);
  */
 free_fixup_function get_fixup_free(fixup_function f);
 
-void set_sip_rpc_mode(int mode);
-int get_sip_rpc_mode(void);
+void set_child_sip_rpc_mode(void);
+void set_child_rpc_sip_mode(void);
+int is_sip_worker(int rank);
 int is_rpc_worker(int rank);
 
 #endif /* sr_module_h */




More information about the sr-dev mailing list