Module: kamailio Branch: master Commit: 74825c896dacd3f39948395cebfcf7b6e0730b51 URL: https://github.com/kamailio/kamailio/commit/74825c896dacd3f39948395cebfcf7b6...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2017-11-10T09:23:34+01:00
dialog: set the end time stamp immediately after going into deleted state
- checks to see if time stamps are set when testing if dialogs lasted too long in intermediary states
---
Modified: src/modules/dialog/dlg_handlers.c Modified: src/modules/dialog/dlg_hash.c
---
Diff: https://github.com/kamailio/kamailio/commit/74825c896dacd3f39948395cebfcf7b6... Patch: https://github.com/kamailio/kamailio/commit/74825c896dacd3f39948395cebfcf7b6...
---
diff --git a/src/modules/dialog/dlg_handlers.c b/src/modules/dialog/dlg_handlers.c index dcd06a845d..b6ce4d2bbd 100644 --- a/src/modules/dialog/dlg_handlers.c +++ b/src/modules/dialog/dlg_handlers.c @@ -456,6 +456,10 @@ static void dlg_onreply(struct cell* t, int type, struct tmcb_params *param) event = DLG_EVENT_RPL3xx;
next_state_dlg( dlg, event, &old_state, &new_state, &unref); + if(new_state==DLG_STATE_DELETED && old_state!=DLG_STATE_DELETED) { + /* set end time */ + dlg->end_ts = (unsigned int)(time(0)); + } if(dlg_run_event_route(dlg, (rpl==FAKED_REPLY)?NULL:rpl, old_state, new_state)<0) { /* dialog is gone */ @@ -530,11 +534,6 @@ static void dlg_onreply(struct cell* t, int type, struct tmcb_params *param) goto done; }
- if(new_state==DLG_STATE_DELETED && old_state!=DLG_STATE_DELETED) { - /* set end time */ - dlg->end_ts = (unsigned int)(time(0)); - } - if ( new_state==DLG_STATE_DELETED && (old_state==DLG_STATE_UNCONFIRMED || old_state==DLG_STATE_EARLY) ) { diff --git a/src/modules/dialog/dlg_hash.c b/src/modules/dialog/dlg_hash.c index e9b0af65ea..1f108f0f8a 100644 --- a/src/modules/dialog/dlg_hash.c +++ b/src/modules/dialog/dlg_hash.c @@ -232,7 +232,7 @@ int dlg_clean_run(ticks_t ti) while (dlg) { tdlg = dlg; dlg = dlg->next; - if(tdlg->state==DLG_STATE_UNCONFIRMED + if(tdlg->state==DLG_STATE_UNCONFIRMED && tdlg->init_ts>0 && tdlg->init_ts<tm-dlg_early_timeout) { /* dialog in early state older than 5min */ LM_NOTICE("dialog in early state is too old (%p ref %d)\n", @@ -240,7 +240,7 @@ int dlg_clean_run(ticks_t ti) unlink_unsafe_dlg(&d_table->entries[i], tdlg); destroy_dlg(tdlg); } - if(tdlg->state==DLG_STATE_CONFIRMED_NA + if(tdlg->state==DLG_STATE_CONFIRMED_NA && tdlg->start_ts>0 && tdlg->start_ts<tm-dlg_noack_timeout) { if(update_dlg_timer(&tdlg->tl, 10)<0) { LM_ERR("failed to update dialog lifetime in long non-ack state\n"); @@ -248,7 +248,8 @@ int dlg_clean_run(ticks_t ti) tdlg->lifetime = 10; tdlg->dflags |= DLG_FLAG_CHANGED; } - if(tdlg->state==DLG_STATE_DELETED && tdlg->end_ts<tm-300) { + if(tdlg->state==DLG_STATE_DELETED && tdlg->end_ts>0 + && tdlg->end_ts<tm-300) { /* dialog in deleted state older than 5min */ LM_NOTICE("dialog in delete state is too old (%p ref %d)\n", tdlg, tdlg->ref);