Browse code

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

Daniel-Constantin Mierla authored on 10/11/2017 08:23:34
Showing 2 changed files
... ...
@@ -456,6 +456,10 @@ static void dlg_onreply(struct cell* t, int type, struct tmcb_params *param)
456 456
 		event = DLG_EVENT_RPL3xx;
457 457
 
458 458
 	next_state_dlg( dlg, event, &old_state, &new_state, &unref);
459
+	if(new_state==DLG_STATE_DELETED && old_state!=DLG_STATE_DELETED) {
460
+		/* set end time */
461
+		dlg->end_ts = (unsigned int)(time(0));
462
+	}
459 463
 	if(dlg_run_event_route(dlg, (rpl==FAKED_REPLY)?NULL:rpl, old_state,
460 464
 			new_state)<0) {
461 465
 		/* dialog is gone */
... ...
@@ -530,11 +534,6 @@ static void dlg_onreply(struct cell* t, int type, struct tmcb_params *param)
530 530
 		goto done;
531 531
 	}
532 532
 
533
-	if(new_state==DLG_STATE_DELETED && old_state!=DLG_STATE_DELETED) {
534
-		/* set end time */
535
-		dlg->end_ts = (unsigned int)(time(0));
536
-	}
537
-
538 533
 	if ( new_state==DLG_STATE_DELETED
539 534
 				&& (old_state==DLG_STATE_UNCONFIRMED
540 535
 					|| old_state==DLG_STATE_EARLY) ) {
... ...
@@ -232,7 +232,7 @@ int dlg_clean_run(ticks_t ti)
232 232
 		while (dlg) {
233 233
 			tdlg = dlg;
234 234
 			dlg = dlg->next;
235
-			if(tdlg->state==DLG_STATE_UNCONFIRMED
235
+			if(tdlg->state==DLG_STATE_UNCONFIRMED && tdlg->init_ts>0
236 236
 					&& tdlg->init_ts<tm-dlg_early_timeout) {
237 237
 				/* dialog in early state older than 5min */
238 238
 				LM_NOTICE("dialog in early state is too old (%p ref %d)\n",
... ...
@@ -240,7 +240,7 @@ int dlg_clean_run(ticks_t ti)
240 240
 				unlink_unsafe_dlg(&d_table->entries[i], tdlg);
241 241
 				destroy_dlg(tdlg);
242 242
 			}
243
-			if(tdlg->state==DLG_STATE_CONFIRMED_NA
243
+			if(tdlg->state==DLG_STATE_CONFIRMED_NA && tdlg->start_ts>0
244 244
 					&& tdlg->start_ts<tm-dlg_noack_timeout) {
245 245
 				if(update_dlg_timer(&tdlg->tl, 10)<0) {
246 246
 					LM_ERR("failed to update dialog lifetime in long non-ack state\n");
... ...
@@ -248,7 +248,8 @@ int dlg_clean_run(ticks_t ti)
248 248
 				tdlg->lifetime = 10;
249 249
 				tdlg->dflags |= DLG_FLAG_CHANGED;
250 250
 			}
251
-			if(tdlg->state==DLG_STATE_DELETED && tdlg->end_ts<tm-300) {
251
+			if(tdlg->state==DLG_STATE_DELETED && tdlg->end_ts>0
252
+					&& tdlg->end_ts<tm-300) {
252 253
 				/* dialog in deleted state older than 5min */
253 254
 				LM_NOTICE("dialog in delete state is too old (%p ref %d)\n",
254 255
 						tdlg, tdlg->ref);