Просмотр исходного кода

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 15 лет назад
Родитель
Сommit
75e52b43af
1 измененных файлов с 18 добавлено и 4 удалено
  1. 18 4
      modules/tm/tm.c

+ 18 - 4
modules/tm/tm.c

@@ -902,7 +902,7 @@ static int t_check_status(struct sip_msg* msg, char *p1, char *foo)
 	str tmp;
 	str tmp;
 	
 	
 	fp = (fparam_t*)p1;
 	fp = (fparam_t*)p1;
-	
+	t = 0;
 	/* first get the transaction */
 	/* first get the transaction */
 	if (t_check(msg, 0 ) == -1) return -1;
 	if (t_check(msg, 0 ) == -1) return -1;
 	if ((t = get_t()) == 0) {
 	if ((t = get_t()) == 0) {
@@ -989,11 +989,23 @@ static int t_check_status(struct sip_msg* msg, char *p1, char *foo)
 		regfree(re);
 		regfree(re);
 		pkg_free(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;
 	if (n!=0) return -1;
 	return 1;
 	return 1;
 
 
  error:
  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 (s) pkg_free(s);
 	if ((fp->type != FPARAM_REGEX) && re) {
 	if ((fp->type != FPARAM_REGEX) && re) {
 		regfree(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
 		   Note: this is needed only in the CORE_ONREPLY_ROUTE and not also in
 		   the TM_ONREPLY_ROUTE.
 		   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 {
 	} else {
 		LOG(L_CRIT, "BUG: w_t_reply entered in unsupported mode\n");
 		LOG(L_CRIT, "BUG: w_t_reply entered in unsupported mode\n");
 		ret = -1;
 		ret = -1;