Bläddra i källkod

- obsolete code removed for the sake of clarity
- CANCEL terminates retransmission timers properly

Jan Janak 20 år sedan
förälder
incheckning
fe04f09564
8 ändrade filer med 35 tillägg och 103 borttagningar
  1. 0 13
      modules/tm/h_table.c
  2. 14 21
      modules/tm/t_cancel.c
  3. 0 3
      modules/tm/t_cancel.h
  4. 0 15
      modules/tm/t_funcs.c
  5. 0 4
      modules/tm/t_funcs.h
  6. 21 32
      modules/tm/t_fwd.c
  7. 0 9
      modules/tm/t_msgbuilder.c
  8. 0 6
      modules/tm/t_reply.h

+ 0 - 13
modules/tm/h_table.c

@@ -382,19 +382,6 @@ void insert_into_hash_table_unsafe( struct cell * p_cell, unsigned int _hash )
 }
 
 
-
-#ifdef _OBSOLETED
-void insert_into_hash_table( struct cell * p_cell)
-{
-	LOCK_HASH(p_cell->hash_index);
-	insert_into_hash_table_unsafe(  p_cell );
-	UNLOCK_HASH(p_cell->hash_index);
-}
-#endif
-
-
-
-
 /*  Un-link a  cell from hash_table, but the cell itself is not released */
 void remove_from_hash_table_unsafe( struct cell * p_cell)
 {

+ 14 - 21
modules/tm/t_cancel.c

@@ -97,42 +97,35 @@ void cancel_branch( struct cell *t, int branch )
 	}
 #	endif
 
-	if (t->uac[branch].last_received<100) {
+	if (t->uac[branch].last_received < 100) {
 		DBG("DEBUG: cancel_branch: no response ever received: "
 		    "giving up on cancel\n");
 		return;
 	}
-
-	cancel=build_cancel(t, branch, &len);
+	
+	cancel = build_local(t, branch, &len, CANCEL, CANCEL_LEN, &t->to);
 	if (!cancel) {
 		LOG(L_ERR, "ERROR: attempt to build a CANCEL failed\n");
 		return;
 	}
-	/* install cancel now */
-	crb->buffer=cancel;
-	crb->buffer_len=len;
-	crb->dst=irb->dst;
-	crb->branch=branch;
-	/* TO_REMOVE
-	crb->retr_timer.payload=crb->fr_timer.payload=crb;
-	*/
+
+	     /* install cancel now */
+	crb->buffer = cancel;
+	crb->buffer_len = len;
+	crb->dst = irb->dst;
+	crb->branch = branch;
+
 	/* label it as cancel so that FR timer can better now how to
 	   deal with it */
-	crb->activ_type=TYPE_LOCAL_CANCEL;
+	crb->activ_type = TYPE_LOCAL_CANCEL;
 
-    DBG("DEBUG: cancel_branch: sending cancel...\n");
+	DBG("DEBUG: cancel_branch: sending cancel...\n");
 	SEND_BUFFER( crb );
-
-    /*sets and starts the FINAL RESPONSE timer */
+	
+	     /*sets and starts the FINAL RESPONSE timer */
 	start_retr( crb );
 }
 
-char *build_cancel(struct cell *Trans,unsigned int branch,
-	unsigned int *len )
-{
-	return build_local( Trans, branch, len,
-		CANCEL, CANCEL_LEN, &Trans->to );
-}
 
 /* fifo command to cancel a pending call (Uli)
   Syntax:

+ 0 - 3
modules/tm/t_cancel.h

@@ -58,9 +58,6 @@ int fifo_uac_cancel( FILE* stream, char *response_file );
 
 int unixsock_uac_cancel(str* msg);
 
-char *build_cancel(struct cell *Trans,unsigned int branch,
-	unsigned int *len );
-
 inline short static should_cancel_branch( struct cell *t, int b )
 {
 	int last_received;

+ 0 - 15
modules/tm/t_funcs.c

@@ -92,21 +92,6 @@ int send_pr_buffer(	struct retr_buf *rb, void *buf, int len
 	}
 }
 
-#ifdef _OBSOLETED
-void start_retr( struct retr_buf *rb )
-{
-	if (rb->dst.proto==PROTO_UDP) {
-		rb->retr_list=RT_T1_TO_1;
-		set_timer( &rb->retr_timer, RT_T1_TO_1 );
-	}
-	set_timer( &rb->fr_timer, FR_TIMER_LIST );
-}
-#endif
-
-
-
-
-
 void tm_shutdown()
 {
 

+ 0 - 4
modules/tm/t_funcs.h

@@ -177,10 +177,6 @@ int get_ip_and_port_from_uri( str* uri , unsigned int *param_ip,
 
 void put_on_wait(  struct cell  *Trans  );
 
-#ifdef _OBSOLETED
-void start_retr( struct retr_buf *rb );
-#endif
-
 void cleanup_localcancel_timers( struct cell *t );
 
 int t_relay_to( struct sip_msg  *p_msg ,

+ 21 - 32
modules/tm/t_fwd.c

@@ -358,7 +358,7 @@ error:
 void e2e_cancel( struct sip_msg *cancel_msg, 
 	struct cell *t_cancel, struct cell *t_invite )
 {
-	branch_bm_t cancel_bm;
+	branch_bm_t cancel_bm, tmp_bm;
 	int i;
 	int lowest_error;
 	str backup_uri;
@@ -389,16 +389,31 @@ void e2e_cancel( struct sip_msg *cancel_msg,
 	cancel_msg->parsed_uri=backup_parsed_uri;
 
 	/* send them out */
-	for (i=0; i<t_cancel->nr_of_outgoings; i++) {
-		if (cancel_bm & (1<<i)) {
-			if (SEND_BUFFER( &t_cancel->uac[i].request)==-1) {
+	for (i = 0; i < t_cancel->nr_of_outgoings; i++) {
+		if (cancel_bm & (1 << i)) {
+			     /* Provisional reply received on this branch, send CANCEL */
+			     /* No need to stop timers as they have already been stopped by the reply */
+			if (SEND_BUFFER(&t_cancel->uac[i].request) == -1) {
 				LOG(L_ERR, "ERROR: e2e_cancel: send failed\n");
 			}
-			start_retr( &t_cancel->uac[i].request );
+			start_retr(&t_cancel->uac[i].request);
+		} else {
+			if (t_invite->uac[i].last_received < 100) {
+				     /* No provisional response received, stop
+				      * retransmission timers
+				      */
+				reset_timer(&t_invite->uac[i].request.retr_timer);
+				reset_timer(&t_invite->uac[i].request.fr_timer);
+
+				     /* Generate faked reply */
+				LOCK_REPLIES(t_invite);
+				if (relay_reply(t_invite, FAKED_REPLY, i, 487, &tmp_bm) == RPS_ERROR) {
+					lowest_error = -1;
+				}
+			}
 		}
 	}
 
-
 	/* if error occurred, let it know upstream (final reply
 	   will also move the transaction on wait state
 	*/
@@ -418,32 +433,6 @@ void e2e_cancel( struct sip_msg *cancel_msg,
 		DBG("DEBUG: e2e_cancel: e2e cancel -- no more pending branches\n");
 		t_reply( t_cancel, cancel_msg, 200, CANCEL_DONE );
 	}
-
-#ifdef LOCAL_487
-
-	/* local 487s have been deprecated -- it better handles
-	 * race conditions (UAS sending 200); hopefully there are
-	 * no longer UACs who go crazy waiting for the 487 whose
-	 * forwarding is being blocked by other unresponsive branch
-	 */
-
-	/* 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");
-	/* in case that something in the meantime has been sent upstream
-	   (like if FR hit at the same time), don't try to send */
-	if (t_invite->uas.status>=200) return;
-	/* there is still a race-condition -- the FR can hit now; that's
-	   not too bad -- we take care in t_reply's REPLY_LOCK; in
-	   the worst case, both this t_reply and other replier will
-	   try, and the later one will result in error message 
-	   "can't reply twice"
-	*/
-	t_reply(t_invite, t_invite->uas.request, 487, CANCELED );
-#endif
 }
 
 

+ 0 - 9
modules/tm/t_msgbuilder.c

@@ -89,15 +89,6 @@ char *build_local(struct cell *Trans,unsigned int branch,
 	str branch_str;
 	struct hostport hp;
 
-#ifdef _OBSO
-	if ( Trans->uac[branch].last_received<100)
-	{
-		DBG("DEBUG: build_local: no response ever received"
-			" : dropping local request! \n");
-		goto error;
-	}
-#endif
-
 	/* method, separators, version: "CANCEL sip:[email protected] SIP/2.0" */
 	*len=SIP_VERSION_LEN + method_len + 2 /* spaces */ + CRLF_LEN;
 	*len+=Trans->uac[branch].uri.len;

+ 0 - 6
modules/tm/t_reply.h

@@ -95,11 +95,6 @@ int t_retransmit_reply( /* struct sip_msg * */  );
  * returns 1 if everything was OK or -1 for error
  */
 
-#ifdef _OBSO
-int t_reply_light( struct cell *trans, char* buf, unsigned int len,
-		   unsigned int code, char * text,
-		   char *to_tag, unsigned int to_tag_len);
-#endif
 
 int t_reply_with_body( struct cell *trans, unsigned int code, 
 		       char * text, char * body, char * new_header, char * to_tag );
@@ -149,4 +144,3 @@ int fifo_t_reply( FILE *stream, char *response_file );
 int unixsock_t_reply(str* msg);
 
 #endif
-