Module: sip-router Branch: master Commit: c70823c0454561dda63eb1e95f66bd96605474db URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=c70823c0...
Author: Federico Cabiddu federico.cabiddu@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: Wed Jan 8 10:43:00 2014 +0100
modules/dialog: added parameter and dialog property to disable timeout reset
---
modules/dialog/dialog.c | 14 ++++++++++++++ modules/dialog/dlg_handlers.c | 7 +++++-- modules/dialog/dlg_hash.h | 1 + 3 files changed, 20 insertions(+), 2 deletions(-)
diff --git a/modules/dialog/dialog.c b/modules/dialog/dialog.c index 8d7be33..4072981 100644 --- a/modules/dialog/dialog.c +++ b/modules/dialog/dialog.c @@ -123,6 +123,7 @@ int active_dlgs_cnt = 0; int early_dlgs_cnt = 0; int detect_spirals = 1; int dlg_send_bye = 0; +int timeout_noreset = 0; stat_var *active_dlgs = 0; stat_var *processed_dlgs = 0; stat_var *expired_dlgs = 0; @@ -281,6 +282,7 @@ static param_export_t mod_params[]={ { "xavp_cfg", STR_PARAM, &dlg_xavp_cfg.s }, { "ka_timer", INT_PARAM, &dlg_ka_timer }, { "ka_interval", INT_PARAM, &dlg_ka_interval }, + { "timeout_noreset", INT_PARAM, &timeout_noreset }, { 0,0,0 } };
@@ -577,6 +579,11 @@ static int mod_init(void) return -1; }
+ if (timeout_noreset != 0 && timeout_noreset != 1) { + LM_ERR("invalid value %d for timeout_noreset param!!\n",timeout_noreset); + return -1; + } + /* if statistics are disabled, prevent their registration to core */ if (dlg_enable_stats==0) exports.stats = 0; @@ -1193,6 +1200,13 @@ static int w_dlg_set_property(struct sip_msg *msg, char *prop, char *s2) d->iflags |= DLG_IFLAG_KA_DST; dlg_release(d); } + } else if(val.len==15 && strncmp(val.s, "timeout-noreset", 15)==0) { + dctx->iflags |= DLG_IFLAG_TIMER_NORESET; + d = dlg_get_by_iuid(&dctx->iuid); + if(d!=NULL) { + d->iflags |= DLG_IFLAG_TIMER_NORESET; + dlg_release(d); + } } else { LM_ERR("unknown property value [%.*s]\n", val.len, val.s); return -1; diff --git a/modules/dialog/dlg_handlers.c b/modules/dialog/dlg_handlers.c index 9393d7f..058131b 100644 --- a/modules/dialog/dlg_handlers.c +++ b/modules/dialog/dlg_handlers.c @@ -82,6 +82,7 @@ static int default_timeout; /*!< default dialog timeout */ static int seq_match_mode; /*!< dlg_match mode */ static int shutdown_done = 0; /*!< 1 when destroy_dlg_handlers was called */ extern int detect_spirals; +extern int timeout_noreset; extern int initial_cbs_inscript; extern int dlg_send_bye; extern int dlg_event_rt[DLG_EVENTRT_MAX]; @@ -1085,7 +1086,7 @@ void dlg_onroute(struct sip_msg* req, str *route_params, void *param) dlg_cell_t *dlg; dlg_iuid_t *iuid; str val, callid, ftag, ttag; - int h_entry, h_id, new_state, old_state, unref, event, timeout; + int h_entry, h_id, new_state, old_state, unref, event, timeout, reset; unsigned int dir; int ret = 0;
@@ -1258,7 +1259,9 @@ void dlg_onroute(struct sip_msg* req, str *route_params, void *param) if (timeout!=default_timeout) { dlg->lifetime = timeout; } - if (new_state!=DLG_STATE_EARLY) { + reset = !((dlg->iflags & DLG_IFLAG_TIMER_NORESET) || timeout_noreset) + + if ((new_state!=DLG_STATE_EARLY) && (old_state!=DLG_STATE_CONFIRMED || reset)) { if (update_dlg_timer( &dlg->tl, dlg->lifetime )==-1) { LM_ERR("failed to update dialog lifetime\n"); } else { diff --git a/modules/dialog/dlg_hash.h b/modules/dialog/dlg_hash.h index 4bfc911..6994256 100644 --- a/modules/dialog/dlg_hash.h +++ b/modules/dialog/dlg_hash.h @@ -85,6 +85,7 @@ #define DLG_IFLAG_TIMEOUTBYE (1<<0) /*!< send bye on time-out */ #define DLG_IFLAG_KA_SRC (1<<1) /*!< send keep alive to src */ #define DLG_IFLAG_KA_DST (1<<2) /*!< send keep alive to dst */ +#define DLG_IFLAG_TIMER_NORESET (1<<3) /*!< don't reset dialog timers on in-dialog messages reception */
#define DLG_CALLER_LEG 0 /*!< attribute that belongs to a caller leg */ #define DLG_CALLEE_LEG 1 /*!< attribute that belongs to a callee leg */