Răsfoiți Sursa

cancel bug fixes

Jiri Kuthan 23 ani în urmă
părinte
comite
141123d45c
4 a modificat fișierele cu 34 adăugiri și 10 ștergeri
  1. 6 0
      modules/tm/config.h
  2. 13 4
      modules/tm/t_fwd.c
  3. 11 4
      modules/tm/t_lookup.c
  4. 4 2
      modules/tm/t_reply.c

+ 6 - 0
modules/tm/config.h

@@ -51,4 +51,10 @@
 #define MAX_HEADER	1024
 #define MAX_BODY	1024
 #define MAX_DST	512
+
+/* messages generated by server */
+#define CANCELLING "cancelling"
+#define CANCEL_DONE "ok -- no more pending branches"
+#define CANCELLED "Request cancelled"
+
 #endif

+ 13 - 4
modules/tm/t_fwd.c

@@ -19,6 +19,7 @@
 #include "t_lookup.h"
 #include "t_fwd.h"
 #include "fix_lumps.h"
+#include "config.h"
 
 
 #ifdef _OBSOLETED
@@ -243,6 +244,9 @@ void e2e_cancel( struct sip_msg *cancel_msg,
 	backup_uri=cancel_msg->new_uri;
 	/* determine which branches to cancel ... */
 	which_cancel( t_invite, &cancel_bm );
+	t_cancel->nr_of_outgoings=t_invite->nr_of_outgoings;
+	/* fix label -- it must be same for reply matching */
+	t_cancel->label=t_invite->label;
 	/* ... and install CANCEL UACs */
 	for (i=0; i<t_invite->nr_of_outgoings; i++)
 		if (cancel_bm & (1<<i)) {
@@ -250,8 +254,6 @@ void e2e_cancel( struct sip_msg *cancel_msg,
 			if (ret<0) cancel_bm &= ~(1<<i);
 			if (ret<lowest_error) lowest_error=ret;
 		}
-	t_cancel->nr_of_outgoings=t_invite->nr_of_outgoings;
-	t_cancel->label=t_invite->label;
 	cancel_msg->new_uri=backup_uri;
 
 	/* send them out */
@@ -276,14 +278,21 @@ void e2e_cancel( struct sip_msg *cancel_msg,
 	*/
 	} else if (cancel_bm) {
 		DBG("DEBUG: e2e_cancel: e2e cancel proceeding\n");
-		t_reply( t_cancel, cancel_msg, 100, "trying to cancel" );
+		t_reply( t_cancel, cancel_msg, 200, CANCELLING );
 	/* if the transaction exists, but there is no more pending
 	   branch, tell usptream we're done
 	*/
 	} else {
 		DBG("DEBUG: e2e_cancel: e2e cancel -- no more pending branches\n");
-		t_reply( t_cancel, cancel_msg, 200, "ok, no more pending branches" );
+		t_reply( t_cancel, cancel_msg, 200, CANCEL_DONE );
 	}
+	/* we could await downstream UAS's 487 replies; however,
+	   if some of the branches does not do that, we could wait
+	   long time and annoy upstream UAC which wants to see 
+	   a result of CANCEL quickly
+	*/
+	DBG("DEBUG: e2e_cancel: sending 487\n");
+	t_reply(t_invite, t_invite->uas.request, 487, CANCELLED );
 }
 
 

+ 11 - 4
modules/tm/t_lookup.c

@@ -292,16 +292,18 @@ struct cell* t_lookupOriginalT(  struct s_table* hash_table ,
 			continue;
 
 		/* found */
-		REF( p_cell );
-		UNLOCK_HASH(hash_index);
 		DBG("DEBUG: t_lookupOriginalT: canceled transaction"
 			" found (%p)! \n",p_cell );
+		REF_UNSAFE( p_cell );
+		UNLOCK_HASH(hash_index);
+		DBG("DEBUG: t_lookupOriginalT completed\n");
 		return p_cell;
 	}
 
 	/* no transaction found */
-	UNLOCK_HASH(hash_index);
 	DBG("DEBUG: t_lookupOriginalT: no CANCEL maching found! \n" );
+	UNLOCK_HASH(hash_index);
+	DBG("DEBUG: t_lookupOriginalT completed\n");
 	return 0;
 }
 
@@ -430,7 +432,12 @@ int t_reply_matching( struct sip_msg *p_msg , int *p_branch )
 			&& memcmp( cseq_method.s, req_method.s, cseq_method.len )==0)
 			/* or it is a local cancel */
 			|| (is_cancel && p_cell->is_invite 
-				&& p_cell->uac[branch_id].local_cancel.buffer )))
+				/* commented out -- should_cancel_branch set it to
+				   BUSY_BUFFER to avoid collisions with repliesl;
+				   thus, we test here by bbuffer size
+				*/
+				/* && p_cell->uac[branch_id].local_cancel.buffer ))) */
+				&& p_cell->uac[branch_id].local_cancel.buffer_len ))) 
 			continue;
 
 

+ 4 - 2
modules/tm/t_reply.c

@@ -527,8 +527,10 @@ int t_on_reply( struct sip_msg  *p_msg )
 	msg_status=p_msg->REPLY_STATUS;
 
 	uac=&t->uac[branch];
-	DBG("DEBUG: t_on_reply: org. status uas=%d, uac[%d]=%d local=%d)\n",
-		t->uas.status, branch, uac->last_received, t->local);
+	DBG("DEBUG: t_on_reply: org. status uas=%d, "
+		"uac[%d]=%d local=%d is_invite=%d)\n",
+		t->uas.status, branch, uac->last_received, 
+		t->local, t->is_invite);
 
 	/* it's a cancel ... ? */
 	if (get_cseq(p_msg)->method.len==CANCEL_LEN