[sr-dev] git:master: tm: t_check_status & t_reply main onreply_route fix

Andrei Pelinescu-Onciul andrei at iptel.org
Mon Feb 22 19:46:41 CET 2010


Module: sip-router
Branch: master
Commit: 75e52b43af0a445b18ccf17e0558da1f41e10337
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=75e52b43af0a445b18ccf17e0558da1f41e10337

Author: Andrei Pelinescu-Onciul <andrei at iptel.org>
Committer: Andrei Pelinescu-Onciul <andrei at iptel.org>
Date:   Mon Feb 22 19:38:40 2010 +0100

tm: t_check_status & t_reply main onreply_route fix

- t_check_status: in some situations t_check_status left the
  transaction referenced when called from main onreply_route (e.g.
  t_check_status(); drop )
- t_reply: unref the transaction only when called from the main
  onreply_route and not from tm onreply route

---

 modules/tm/tm.c |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/modules/tm/tm.c b/modules/tm/tm.c
index 513dc99..2b35681 100644
--- a/modules/tm/tm.c
+++ b/modules/tm/tm.c
@@ -902,7 +902,7 @@ static int t_check_status(struct sip_msg* msg, char *p1, char *foo)
 	str tmp;
 	
 	fp = (fparam_t*)p1;
-	
+	t = 0;
 	/* first get the transaction */
 	if (t_check(msg, 0 ) == -1) return -1;
 	if ((t = get_t()) == 0) {
@@ -989,11 +989,23 @@ static int t_check_status(struct sip_msg* msg, char *p1, char *foo)
 		regfree(re);
 		pkg_free(re);
 	}
-
+	
+	if (unlikely(t && is_route_type(CORE_ONREPLY_ROUTE))){
+		/* t_check() above has the side effect of setting T and
+		   REFerencing T => we must unref and unset it.  */
+		UNREF( t );
+		set_t(T_UNDEFINED, T_BR_UNDEFINED);
+	}
 	if (n!=0) return -1;
 	return 1;
 
  error:
+	if (unlikely(t && is_route_type(CORE_ONREPLY_ROUTE))){
+		/* t_check() above has the side effect of setting T and
+		   REFerencing T => we must unref and unset it.  */
+		UNREF( t );
+		set_t(T_UNDEFINED, T_BR_UNDEFINED);
+	}
 	if (s) pkg_free(s);
 	if ((fp->type != FPARAM_REGEX) && re) {
 		regfree(re);
@@ -1268,8 +1280,10 @@ inline static int w_t_reply(struct sip_msg* msg, char* p1, char* p2)
 		   Note: this is needed only in the CORE_ONREPLY_ROUTE and not also in
 		   the TM_ONREPLY_ROUTE.
 		 */
-		UNREF( t );
-		set_t(T_UNDEFINED, T_BR_UNDEFINED);
+		if (is_route_type(CORE_ONREPLY_ROUTE)) {
+			UNREF( t );
+			set_t(T_UNDEFINED, T_BR_UNDEFINED);
+		}
 	} else {
 		LOG(L_CRIT, "BUG: w_t_reply entered in unsupported mode\n");
 		ret = -1;




More information about the sr-dev mailing list