[sr-dev] git:master:95bd694e: evapi: dispatcher worker to send event data directly
Daniel-Constantin Mierla
miconda at gmail.com
Fri Nov 3 08:29:10 CET 2017
Module: kamailio
Branch: master
Commit: 95bd694e75c250d8b26cac071bff2e48e0eb9062
URL: https://github.com/kamailio/kamailio/commit/95bd694e75c250d8b26cac071bff2e48e0eb9062
Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2017-11-03T08:26:36+01:00
evapi: dispatcher worker to send event data directly
- instead of trying to send over internal socket, which is open only for
reading in this process
---
Modified: src/modules/evapi/evapi_dispatch.c
Modified: src/modules/evapi/evapi_mod.c
---
Diff: https://github.com/kamailio/kamailio/commit/95bd694e75c250d8b26cac071bff2e48e0eb9062.diff
Patch: https://github.com/kamailio/kamailio/commit/95bd694e75c250d8b26cac071bff2e48e0eb9062.patch
---
diff --git a/src/modules/evapi/evapi_dispatch.c b/src/modules/evapi/evapi_dispatch.c
index 2aaaf1e6c9..40ab0e5ed1 100644
--- a/src/modules/evapi/evapi_dispatch.c
+++ b/src/modules/evapi/evapi_dispatch.c
@@ -46,6 +46,7 @@ static int _evapi_notify_sockets[2];
static int _evapi_netstring_format = 1;
extern str _evapi_event_callback;
+extern int _evapi_dispatcher_pid;
#define EVAPI_IPADDR_SIZE 64
#define EVAPI_TAG_SIZE 64
@@ -256,6 +257,7 @@ void evapi_close_notify_sockets_child(void)
{
LM_DBG("closing the notification socket used by children\n");
close(_evapi_notify_sockets[1]);
+ _evapi_notify_sockets[1] = -1;
}
/**
@@ -265,6 +267,7 @@ void evapi_close_notify_sockets_parent(void)
{
LM_DBG("closing the notification socket used by parent\n");
close(_evapi_notify_sockets[0]);
+ _evapi_notify_sockets[0] = -1;
}
/**
@@ -730,11 +733,21 @@ int _evapi_relay(str *evdata, str *ctag, int unicast)
emsg->unicast = unicast;
}
- LM_DBG("sending [%p] [%.*s] (%d)\n", emsg, emsg->data.len, emsg->data.s, emsg->data.len);
- len = write(_evapi_notify_sockets[1], &emsg, sizeof(evapi_msg_t*));
- if(len<=0) {
- LM_ERR("failed to pass the pointer to evapi dispatcher\n");
- return -1;
+ LM_DBG("sending [%p] [%.*s] (%d)\n", emsg, emsg->data.len, emsg->data.s,
+ emsg->data.len);
+ if(_evapi_notify_sockets[1]!=-1) {
+ len = write(_evapi_notify_sockets[1], &emsg, sizeof(evapi_msg_t*));
+ if(len<=0) {
+ shm_free(emsg);
+ LM_ERR("failed to pass the pointer to evapi dispatcher\n");
+ return -1;
+ }
+ } else {
+ cfg_update();
+ LM_DBG("dispatching [%p] [%.*s] (%d)\n", emsg,
+ emsg->data.len, emsg->data.s, emsg->data.len);
+ evapi_dispatch_notify(emsg);
+ shm_free(emsg);
}
return 0;
}
diff --git a/src/modules/evapi/evapi_mod.c b/src/modules/evapi/evapi_mod.c
index 353027f4c6..e5eac596ae 100644
--- a/src/modules/evapi/evapi_mod.c
+++ b/src/modules/evapi/evapi_mod.c
@@ -52,9 +52,9 @@ static char *_evapi_bind_param = NULL;
static int _evapi_netstring_format_param = 1;
str _evapi_event_callback = STR_NULL;
+int _evapi_dispatcher_pid = -1;
static tm_api_t tmb;
-static int _evapi_dispatcher_pid = -1;
static int mod_init(void);
static int child_init(int);
More information about the sr-dev
mailing list