[sr-dev] git:sr_3.0: tm: safer handling for local transactions and drop_replies!=0

Andrei Pelinescu-Onciul andrei at iptel.org
Wed Dec 23 20:54:00 CET 2009


Module: sip-router
Branch: sr_3.0
Commit: 0fe25e507eccac409f5094cff4240ee5d3224666
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=0fe25e507eccac409f5094cff4240ee5d3224666

Author: Andrei Pelinescu-Onciul <andrei at iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
Date:   Wed Dec 23 20:44:31 2009 +0100

tm: safer handling for local transactions and drop_replies!=0

- if all the replies are dropped in the failure route and the
  transaction is local, return the current reply. This makes the
  code more future safe (currently there is no way for the failure
  route to be executed and hence for replies to be dropped for
  local transactions).

- check for FAKED_REPLY in local_reply() error path.

---

 modules/tm/t_reply.c |   23 +++++++++++++----------
 1 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/modules/tm/t_reply.c b/modules/tm/t_reply.c
index 8dbd1d6..12af017 100644
--- a/modules/tm/t_reply.c
+++ b/modules/tm/t_reply.c
@@ -1248,16 +1248,19 @@ discard:
 
 branches_failed:
 	*should_store=0;
-	*should_relay=-1;
-	/* We have hopefully set tm_error in failure_route when
-	the branches failed. If not, reply with E_UNSPEC */
-	if ((kill_transaction_unsafe(Trans,
-				    tm_error ? tm_error : E_UNSPEC)
-				    ) <=0 ){
-		LOG(L_ERR, "ERROR: t_should_relay_response: "
-			"reply generation failed\n");
+	if (is_local(Trans)){
+		/* for local transactions use the current reply */
+		*should_relay=branch;
+	}else{
+		*should_relay=-1;
+		/* We have hopefully set tm_error in failure_route when
+			the branches failed. If not, reply with E_UNSPEC */
+		if ((kill_transaction_unsafe(Trans,
+				tm_error ? tm_error : E_UNSPEC)) <=0 ){
+			LOG(L_ERR, "ERROR: t_should_relay_response: "
+						"reply generation failed\n");
+		}
 	}
-	
 	return RPS_COMPLETED;
 }
 
@@ -1802,7 +1805,7 @@ error:
 	prepare_to_cancel(t, cancel_bitmap, 0);
 	UNLOCK_REPLIES(t);
 	cleanup_uac_timers(t);
-	if ( get_cseq(p_msg)->method.len==INVITE_LEN
+	if (p_msg && p_msg!=FAKED_REPLY && get_cseq(p_msg)->method.len==INVITE_LEN
 		&& memcmp( get_cseq(p_msg)->method.s, INVITE, INVITE_LEN)==0)
 		cancel_uacs( t, *cancel_bitmap, F_CANCEL_B_KILL);
 	*cancel_bitmap=0; /* we've already took care of everything */




More information about the sr-dev mailing list