Ver Fonte

core: added possibility to know if SIP workers handle RPC commands

- for example when using xmlrpc module, the rpc commands are handled by
  sip workers and may require special sip child initialization
Daniel-Constantin Mierla há 14 anos atrás
pai
commit
37db0ca71d
2 ficheiros alterados com 26 adições e 0 exclusões
  1. 22 0
      sr_module.c
  2. 4 0
      sr_module.h

+ 22 - 0
sr_module.c

@@ -112,6 +112,28 @@ struct sr_module* modules=0;
 int mod_response_cbk_no=0;
 int mod_response_cbk_no=0;
 response_function* mod_response_cbks=0;
 response_function* mod_response_cbks=0;
 
 
+/**
+ * if set to 1, SIP worker processes handle RPC commands as well
+ */
+static int child_sip_rpc_mode = 0;
+
+void set_sip_rpc_mode(int mode)
+{
+	child_sip_rpc_mode = mode;
+}
+
+int get_sip_rpc_mode(void)
+{
+	return child_sip_rpc_mode;
+}
+
+int is_rpc_worker(int rank)
+{
+	if(rank==PROC_RPC || (rank>PROC_MAIN && child_sip_rpc_mode!=0))
+		return 1;
+	return 0;
+}
+
 /* initializes statically built (compiled in) modules*/
 /* initializes statically built (compiled in) modules*/
 int register_builtin_modules()
 int register_builtin_modules()
 {
 {

+ 4 - 0
sr_module.h

@@ -655,4 +655,8 @@ int fixup_free_fparam_2(void** param, int param_no);
  */
  */
 free_fixup_function get_fixup_free(fixup_function f);
 free_fixup_function get_fixup_free(fixup_function f);
 
 
+void set_sip_rpc_mode(int mode);
+int get_sip_rpc_mode(void);
+int is_rpc_worker(int rank);
+
 #endif /* sr_module_h */
 #endif /* sr_module_h */