Browse code

dialog: fix bug when detect_spirals enabled

If detect_spirals enabled and the caller sent an Invite which received a
negative response and then immediately sent another Invite with the
same callid and tag, the module did not create a dialog record for the
second Invite. It wrongly concluded that the Invite is spiraled. This
resulted in missing CDR for that call.
Behavior observed if the first Invite has a small Session-Timer interval
and receives a 422 reply. When the phone sent the second Invite with a
larger Session-Timer, which could have been successful, it was not recorded
by the dialog module.

(manual cherry picked from commit 5a78a8b8ec104550a37d8e2ae9005bf87d21e00f)

Anca Vamanu authored on 11/01/2013 09:50:26
Showing 1 changed files
... ...
@@ -693,15 +693,18 @@ int dlg_new_dialog(struct sip_msg *msg, struct cell *t)
693 693
 		dlg = get_dlg(&callid, &ftag, &ttag, &dir);
694 694
 		if (dlg)
695 695
 		{
696
-			LM_DBG("Callid '%.*s' found, must be a spiraled request\n",
697
-					callid.len, callid.s);
698
-			spiral_detected = 1;
696
+			if ( dlg->state!=DLG_STATE_DELETED ) {
697
+				LM_DBG("Callid '%.*s' found, must be a spiraled request\n",
698
+						callid.len, callid.s);
699
+				spiral_detected = 1;
699 700
 
700
-			run_dlg_callbacks( DLGCB_SPIRALED, dlg, msg, DLG_DIR_DOWNSTREAM, 0);
701
+				run_dlg_callbacks( DLGCB_SPIRALED, dlg, msg, DLG_DIR_DOWNSTREAM, 0);
701 702
 
702
-			// get_dlg with del==0 has incremented the ref count by 1
703
+				// get_dlg with del==0 has incremented the ref count by 1
704
+				unref_dlg(dlg, 1);
705
+				goto finish;
706
+			}
703 707
 			unref_dlg(dlg, 1);
704
-			goto finish;
705 708
 		}
706 709
 	}
707 710
 	spiral_detected = 0;