Explorar o código

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.
Anca Vamanu %!s(int64=12) %!d(string=hai) anos
pai
achega
5a78a8b8ec
Modificáronse 1 ficheiros con 14 adicións e 10 borrados
  1. 14 10
      modules_k/dialog/dlg_handlers.c

+ 14 - 10
modules_k/dialog/dlg_handlers.c

@@ -805,16 +805,20 @@ int dlg_new_dialog(sip_msg_t *req, struct cell *t, const int run_initial_cbs)
         dlg = get_dlg(&callid, &ftag, &ttag, &dir);
         if (dlg)
         {
-            LM_DBG("Callid '%.*s' found, must be a spiraled request\n",
-                callid.len, callid.s);
-            spiral_detected = 1;
-
-            if (run_initial_cbs)
-                run_dlg_callbacks( DLGCB_SPIRALED, dlg, req, NULL,
-						DLG_DIR_DOWNSTREAM, 0);
-            /* get_dlg() has incremented the ref count by 1
-			 * - it's ok, dlg will be unref at the end of function */
-            goto finish;
+			if ( dlg->state != DLG_STATE_DELETED )
+			{
+				LM_DBG("Callid '%.*s' found, must be a spiraled request\n",
+					callid.len, callid.s);
+				spiral_detected = 1;
+
+				if (run_initial_cbs)
+					run_dlg_callbacks( DLGCB_SPIRALED, dlg, req, NULL,
+							DLG_DIR_DOWNSTREAM, 0);
+				/* get_dlg() has incremented the ref count by 1
+				 * - it's ok, dlg will be unref at the end of function */
+				goto finish;
+			}
+			dlg_release(dlg);
         }
     }
     spiral_detected = 0;