[sr-dev] git:4.4:3ef7c98b: evapi: fixed the communication with dispatcher after initializing it as rpc worker

Daniel-Constantin Mierla miconda at gmail.com
Thu Sep 8 14:56:15 CEST 2016


Module: kamailio
Branch: 4.4
Commit: 3ef7c98b352adba67aec25cbb99a0efa8da25600
URL: https://github.com/kamailio/kamailio/commit/3ef7c98b352adba67aec25cbb99a0efa8da25600

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2016-09-08T14:55:34+02:00

evapi: fixed the communication with dispatcher after initializing it as rpc worker

(cherry picked from commit 72580f250a2322ac1d5e71a92826fd8b11225b04)

---

Modified: modules/evapi/evapi_dispatch.c
Modified: modules/evapi/evapi_mod.c

---

Diff:  https://github.com/kamailio/kamailio/commit/3ef7c98b352adba67aec25cbb99a0efa8da25600.diff
Patch: https://github.com/kamailio/kamailio/commit/3ef7c98b352adba67aec25cbb99a0efa8da25600.patch

---

diff --git a/modules/evapi/evapi_dispatch.c b/modules/evapi/evapi_dispatch.c
index 502809b..846d650 100644
--- a/modules/evapi/evapi_dispatch.c
+++ b/modules/evapi/evapi_dispatch.c
@@ -221,6 +221,8 @@ int evapi_dispatch_notify(char *obuf, int olen)
 		}
 	}
 
+	LM_DBG("the message was sent to %d clients\n", n);
+
 	return n;
 }
 
diff --git a/modules/evapi/evapi_mod.c b/modules/evapi/evapi_mod.c
index b922cac..ab4fa6f 100644
--- a/modules/evapi/evapi_mod.c
+++ b/modules/evapi/evapi_mod.c
@@ -51,6 +51,7 @@ static char *_evapi_bind_param = NULL;
 static int   _evapi_netstring_format_param = 1;
 
 static tm_api_t tmb;
+static int   _evapi_dispatcher_pid = -1;
 
 static int  mod_init(void);
 static int  child_init(int);
@@ -164,16 +165,24 @@ static int child_init(int rank)
 	}
 
 	if (rank!=PROC_MAIN) {
-		evapi_close_notify_sockets_parent();
+		if(_evapi_dispatcher_pid!=getpid()) {
+			evapi_close_notify_sockets_parent();
+		}
 		return 0;
 	}
 
-	pid=fork_process(PROC_RPC, "EvAPI Dispatcher", 1);
+	pid=fork_process(PROC_NOCHLDINIT, "EvAPI Dispatcher", 1);
 	if (pid<0)
 		return -1; /* error */
 	if(pid==0) {
 		/* child */
+		_evapi_dispatcher_pid = getpid();
 
+		/* do child init to allow execution of rpc like functions */
+		if(init_child(PROC_RPC) < 0) {
+			LM_DBG("failed to do RPC child init for dispatcher\n");
+			return -1;
+		}
 		/* initialize the config framework */
 		if (cfg_child_init())
 			return -1;




More information about the sr-dev mailing list