From 59329ddd04831017f25926e4f172b6fba7a5b8b2 Mon Sep 17 00:00:00 2001 From: Frederic-Philippe Metz Date: Fri, 5 Dec 2014 03:16:39 -0500 Subject: [PATCH] VOIPTEST_220_delete delay MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Im Moment wurden die sessions ja nach 30 sekunden hardcoded abgeräumt. Dieser patch macht das konfigurabel. ersetzt den letzten patch "added_delete_delay_for_memory_cleanup.patch". Author: Frederic-Philippe Metz --- README.md | 5 +++++ daemon/call.c | 15 +++++++-------- daemon/call.h | 1 + daemon/main.c | 5 ++++- debian/ngcp-rtpengine-daemon.default | 1 + debian/ngcp-rtpengine-daemon.init | 1 + el/rtpengine.init | 5 +++++ el/rtpengine.sysconfig | 1 + 8 files changed, 25 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index fca851581..7931add40 100644 --- a/README.md +++ b/README.md @@ -181,6 +181,7 @@ option and which are reproduced below: -E, --log-stderr Log on stderr instead of syslog -x, --xmlrpc-format=INT XMLRPC timeout request format to use. 0: SEMS DI, 1: call-id only --num-threads=INT Number of worker threads to create + -d, --delete-delay Delay for deleting a session from memory. --sip-source Use SIP source address by default --dtls-passive Always prefer DTLS passive role @@ -345,6 +346,10 @@ The options are described in more detail below. Enabled the `DTLS=passive` flag for all calls unconditionally. +* -d, --delete-delay + + Delete the call from memory after the specified delay from memory. + * -r, --redis, -R, --redis-db, -b, --b2b-url NGCP-specific options diff --git a/daemon/call.c b/daemon/call.c index 64ba52512..d80d64c5e 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -36,10 +36,6 @@ -#ifndef DELETE_DELAY -#define DELETE_DELAY 30 -#endif - #ifndef PORT_RANDOM_MIN #define PORT_RANDOM_MIN 6 #define PORT_RANDOM_MAX 20 @@ -1093,6 +1089,9 @@ next: if (good) goto out; + if (c->ml_deleted) + goto out; + for (i = c->monologues; i; i = i->next) { ml = i->data; memset(&ml->terminated,0,sizeof(struct timeval)); @@ -2902,15 +2901,15 @@ int call_delete_branch(struct callmaster *m, const str *callid, const str *branc */ ilog(LOG_INFO, "Scheduling deletion of call branch '"STR_FORMAT"' in %d seconds", - STR_FMT(&ml->tag), DELETE_DELAY); - ml->deleted = poller_now + DELETE_DELAY; + STR_FMT(&ml->tag), m->conf.delete_delay); + ml->deleted = poller_now + m->conf.delete_delay; if (!c->ml_deleted || c->ml_deleted > ml->deleted) c->ml_deleted = ml->deleted; goto success_unlock; del_all: - ilog(LOG_INFO, "Scheduling deletion of entire call in %d seconds", DELETE_DELAY); - c->deleted = poller_now + DELETE_DELAY; + ilog(LOG_INFO, "Scheduling deletion of entire call in %d seconds", m->conf.delete_delay); + c->deleted = poller_now + m->conf.delete_delay; rwlock_unlock_w(&c->master_lock); goto success; diff --git a/daemon/call.h b/daemon/call.h index 9b5ea27da..fefc7f033 100644 --- a/daemon/call.h +++ b/daemon/call.h @@ -370,6 +370,7 @@ struct callmaster_config { int port_max; unsigned int timeout; unsigned int silent_timeout; + unsigned int delete_delay; struct redis *redis; char *b2b_url; unsigned char default_tos; diff --git a/daemon/main.c b/daemon/main.c index 006502743..d972c1604 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -107,6 +107,7 @@ static int redis_db = -1; static char *b2b_url; static enum xmlrpc_format xmlrpc_fmt = XF_SEMS; static int num_threads; +static int delete_delay = 30; static void sighandler(gpointer x) { @@ -340,10 +341,11 @@ static void options(int *argc, char ***argv) { { "b2b-url", 'b', 0, G_OPTION_ARG_STRING, &b2b_url, "XMLRPC URL of B2B UA" , "STRING" }, { "log-level", 'L', 0, G_OPTION_ARG_INT, (void *)&log_level,"Mask log priorities above this level","INT" }, { "log-facility",0, 0, G_OPTION_ARG_STRING, &log_facility_s, "Syslog facility to use for logging", "daemon|local0|...|local7"}, - { "log-facility-cdr",0, 0, G_OPTION_ARG_STRING, &log_facility_cdr_s, "Syslog facility to use for logging CDRs", "daemon|local0|...|local7"}, + { "log-facility-cdr",0, 0, G_OPTION_ARG_STRING, &log_facility_cdr_s, "Syslog facility to use for logging CDRs", "daemon|local0|...|local7"}, { "log-stderr", 'E', 0, G_OPTION_ARG_NONE, &_log_stderr, "Log on stderr instead of syslog", NULL }, { "xmlrpc-format",'x', 0, G_OPTION_ARG_INT, &xmlrpc_fmt, "XMLRPC timeout request format to use. 0: SEMS DI, 1: call-id only", "INT" }, { "num-threads", 0, 0, G_OPTION_ARG_INT, &num_threads, "Number of worker threads to create", "INT" }, + { "delete-delay", 'd', 0, G_OPTION_ARG_INT, &delete_delay, "Delay for deleting a session from memory.", "INT" }, { "sip-source", 0, 0, G_OPTION_ARG_NONE, &sip_source, "Use SIP source address by default", NULL }, { "dtls-passive", 0, 0, G_OPTION_ARG_NONE, &dtls_passive_def,"Always prefer DTLS passive role", NULL }, { NULL, } @@ -608,6 +610,7 @@ no_kernel: mc.port_max = port_max; mc.timeout = timeout; mc.silent_timeout = silent_timeout; + mc.delete_delay = delete_delay; mc.default_tos = tos; mc.b2b_url = b2b_url; mc.fmt = xmlrpc_fmt; diff --git a/debian/ngcp-rtpengine-daemon.default b/debian/ngcp-rtpengine-daemon.default index 713d3fe51..20b659cb5 100644 --- a/debian/ngcp-rtpengine-daemon.default +++ b/debian/ngcp-rtpengine-daemon.default @@ -22,3 +22,4 @@ TABLE=0 # LOG_FACILITY=daemon # LOG_FACILITY_CDR=daemon # NUM_THREADS=5 +# DELETE_DELAY=30 \ No newline at end of file diff --git a/debian/ngcp-rtpengine-daemon.init b/debian/ngcp-rtpengine-daemon.init index 4caa2fec8..651e17f6e 100755 --- a/debian/ngcp-rtpengine-daemon.init +++ b/debian/ngcp-rtpengine-daemon.init @@ -71,6 +71,7 @@ OPTIONS="$OPTIONS --table=$TABLE" [ -z "$LOG_FACILITY" ] || OPTIONS="$OPTIONS --log-facility=$LOG_FACILITY" [ -z "$LOG_FACILITY_CDR" ] || OPTIONS="$OPTIONS --log-facility-cdr=$LOG_FACILITY_CDR" [ -z "$NUM_THREADS" ] || OPTIONS="$OPTIONS --num-threads=$NUM_THREADS" +[ -z "$DELETE_DELAY" ] || OPTIONS="$OPTIONS --delete-delay=$DELETE_DELAY" if test "$FORK" = "no" ; then OPTIONS="$OPTIONS --foreground" fi diff --git a/el/rtpengine.init b/el/rtpengine.init index 529d2b6f7..d02e5e8ef 100644 --- a/el/rtpengine.init +++ b/el/rtpengine.init @@ -152,6 +152,11 @@ build_opts() { OPTS+=" --num-threads=$NUM_THREADS" fi + if [[ -n "$DELETE_DELAY" ]] + then + OPTS+=" --delete-delay=$DELETE_DELAY" + fi + if [[ -n "$LOG_FACILITY_CDR" ]] then OPTS+=" --log-facility-cdr=$LOG_FACILITY_CDR" diff --git a/el/rtpengine.sysconfig b/el/rtpengine.sysconfig index 3048c0cbe..430fd9c5e 100644 --- a/el/rtpengine.sysconfig +++ b/el/rtpengine.sysconfig @@ -37,6 +37,7 @@ LISTEN_UDP=127.0.0.1:2222 # IP address and port combination for UDP #LOG_FACILITY=daemon # Syslog facility to use #LOG_FACILITY_CDR=daemon # Syslog facility to write CDRs #NUM_THREADS=5 # How many worker threads to launch +#DELETE_DELAY=30 # Delay to delete session from memory # The following items are for use with NGCP #REDIS=127.0.0.1:6379