Browse code

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

Andrei Pelinescu-Onciul authored on 22/02/2010 18:38:40
Showing 1 changed files
... ...
@@ -902,7 +902,7 @@ static int t_check_status(struct sip_msg* msg, char *p1, char *foo)
902 902
 	str tmp;
903 903
 	
904 904
 	fp = (fparam_t*)p1;
905
-	
905
+	t = 0;
906 906
 	/* first get the transaction */
907 907
 	if (t_check(msg, 0 ) == -1) return -1;
908 908
 	if ((t = get_t()) == 0) {
... ...
@@ -989,11 +989,23 @@ static int t_check_status(struct sip_msg* msg, char *p1, char *foo)
989 989
 		regfree(re);
990 990
 		pkg_free(re);
991 991
 	}
992
-
992
+	
993
+	if (unlikely(t && is_route_type(CORE_ONREPLY_ROUTE))){
994
+		/* t_check() above has the side effect of setting T and
995
+		   REFerencing T => we must unref and unset it.  */
996
+		UNREF( t );
997
+		set_t(T_UNDEFINED, T_BR_UNDEFINED);
998
+	}
993 999
 	if (n!=0) return -1;
994 1000
 	return 1;
995 1001
 
996 1002
  error:
1003
+	if (unlikely(t && is_route_type(CORE_ONREPLY_ROUTE))){
1004
+		/* t_check() above has the side effect of setting T and
1005
+		   REFerencing T => we must unref and unset it.  */
1006
+		UNREF( t );
1007
+		set_t(T_UNDEFINED, T_BR_UNDEFINED);
1008
+	}
997 1009
 	if (s) pkg_free(s);
998 1010
 	if ((fp->type != FPARAM_REGEX) && re) {
999 1011
 		regfree(re);
... ...
@@ -1268,8 +1280,10 @@ inline static int w_t_reply(struct sip_msg* msg, char* p1, char* p2)
1268 1268
 		   Note: this is needed only in the CORE_ONREPLY_ROUTE and not also in
1269 1269
 		   the TM_ONREPLY_ROUTE.
1270 1270
 		 */
1271
-		UNREF( t );
1272
-		set_t(T_UNDEFINED, T_BR_UNDEFINED);
1271
+		if (is_route_type(CORE_ONREPLY_ROUTE)) {
1272
+			UNREF( t );
1273
+			set_t(T_UNDEFINED, T_BR_UNDEFINED);
1274
+		}
1273 1275
 	} else {
1274 1276
 		LOG(L_CRIT, "BUG: w_t_reply entered in unsupported mode\n");
1275 1277
 		ret = -1;