Module: kamailio
Branch: master
Commit: 72580f250a2322ac1d5e71a92826fd8b11225b04
URL:
https://github.com/kamailio/kamailio/commit/72580f250a2322ac1d5e71a92826fd8…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2016-09-08T14:53:48+02:00
evapi: fixed the communication with dispatcher after initializing it as rpc worker
---
Modified: modules/evapi/evapi_dispatch.c
Modified: modules/evapi/evapi_mod.c
---
Diff:
https://github.com/kamailio/kamailio/commit/72580f250a2322ac1d5e71a92826fd8…
Patch:
https://github.com/kamailio/kamailio/commit/72580f250a2322ac1d5e71a92826fd8…
---
diff --git a/modules/evapi/evapi_dispatch.c b/modules/evapi/evapi_dispatch.c
index 1dfc578..57603c4 100644
--- a/modules/evapi/evapi_dispatch.c
+++ b/modules/evapi/evapi_dispatch.c
@@ -271,6 +271,8 @@ int evapi_dispatch_notify(evapi_msg_t *emsg)
}
}
+ 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 cf29471..6cb4e4f 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);
@@ -180,16 +181,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;