Browse Source

- T_CANCELED is set for any E2E CANCEL, making t_is_canceled() usable
for more then checking for out fo order CANCELs (experimental)

Andrei Pelinescu-Onciul 17 years ago
parent
commit
c1deee7e90
2 changed files with 16 additions and 6 deletions
  1. 4 1
      modules/tm/h_table.h
  2. 12 5
      modules/tm/t_fwd.c

+ 4 - 1
modules/tm/h_table.h

@@ -226,7 +226,10 @@ struct totag_elem {
 /* set to one if you want to disallow silent transaction
    dropping when C timer hits */
 #define T_NOISY_CTIMER_FLAG  (1<<2)
-/* transaction canceled */
+/* transaction canceled
+ * WARNING: this flag can be set outside reply lock from e2e_cancel().
+ * If a future flag could be affected by a race w/ e2e_cancel() the code
+ * should be changed.*/
 #define T_CANCELED           (1<<3)
 /* 6xx received => stop forking */
 #define T_6xx            (1<<4) 

+ 12 - 5
modules/tm/t_fwd.c

@@ -72,11 +72,12 @@
  *              t_relay_cancel() introduced -- can be used to relay CANCELs
  *              at the beginning of the script. (Miklos)
  * 2007-06-04  running transaction are canceled hop by hop (andrei)
- *  2007-08-37  In case of DNS failover the new SIP message is constructed
+ * 2007-08-37  In case of DNS failover the new SIP message is constructed
  *              from the message buffer of the failed branch instead of
- *              applying the lumps again, because the per-branch lumps are not saved,
- *              thus, are not available. Set reparse_on_dns_failover to 0 to
- *              revert the change. (Miklos)
+ *              applying the lumps again, because the per-branch lumps are no
+ *              t saved, thus, are not available. Set reparse_on_dns_failover
+ *              to 0 to revert the change. (Miklos)
+ * 2008-06-04  T_CANCELED is now set each time a CANCEL is received (andrei)
  */
 
 #include "defs.h"
@@ -695,9 +696,15 @@ void e2e_cancel( struct sip_msg *cancel_msg,
 		run_trans_callbacks_internal(&t_invite->tmcb_hl, TMCB_E2ECANCEL_IN, 
 										t_invite, &tmcb);
 	}
+	/* mark transaction as canceled, so that no new message are forwarded
+	 * on it and t_is_canceled() returns true 
+	 * WARNING: it's safe to do it without locks, at least for now (in a race
+	 * event even if a flag is unwillingly reset nothing bad will happen),
+	 * however this should be rechecked for any future new flags use.
+	 */
+	t_invite->flags|=T_CANCELED;
 	/* first check if there are any branches */
 	if (t_invite->nr_of_outgoings==0){
-		t_invite->flags|=T_CANCELED;
 		/* no branches yet => force a reply to the invite */
 		t_reply( t_invite, t_invite->uas.request, 487, CANCELED );
 		DBG("DEBUG: e2e_cancel: e2e cancel -- no more pending branches\n");