浏览代码

route_type: branch and onsend route bugs corrected

- Branch and onsend routes did not restore the original
route_type after they have finished the execution,
so subsequent functions that need the route_type failed.
(For example t_relay() in the second branch did not work
if branch or onsend routes of the first branch were executed.)
- get_route_type() macro added.
Miklos Tirpak 16 年之前
父节点
当前提交
593513f8e0
共有 4 个文件被更改,包括 9 次插入1 次删除
  1. 3 0
      modules/tm/t_fwd.c
  2. 1 1
      modules_k/htable/htable.c
  3. 3 0
      onsend.h
  4. 2 0
      route.h

+ 3 - 0
modules/tm/t_fwd.c

@@ -151,6 +151,7 @@ static char *print_uac_request( struct cell *t, struct sip_msg *i_req,
 	struct sip_uri parsed_uri_bak;
 	int parsed_uri_ok_bak, uri_backed_up;
 	str msg_uri_bak;
+	int backup_route_type;
 
 	shbuf=0;
 	msg_uri_bak.s=0; /* kill warnings */
@@ -189,12 +190,14 @@ static char *print_uac_request( struct cell *t, struct sip_msg *i_req,
 
 	if (unlikely(branch_route)) {
 		     /* run branch_route actions if provided */
+		backup_route_type = get_route_type();
 		set_route_type(BRANCH_ROUTE);
 		tm_ctx_set_branch_index(branch+1);
 		if (run_top_route(branch_rt.rlist[branch_route], i_req) < 0) {
 			LOG(L_ERR, "ERROR: print_uac_request: Error in run_top_route\n");
 		}
 		tm_ctx_set_branch_index(0);
+		set_route_type(backup_route_type);
 	}
 
 	/* run the specific callbacks for this transaction */

+ 1 - 1
modules_k/htable/htable.c

@@ -182,7 +182,7 @@ static int child_init(int rank)
 		if(faked_msg_init()<0)
 			return -1;
 		fmsg = faked_msg_next();
-		rtb = route_type;
+		rtb = get_route_type();
 		set_route_type(REQUEST_ROUTE);
 		run_top_route(event_rt.rlist[rt], fmsg);
 		set_route_type(rtb);

+ 3 - 0
onsend.h

@@ -60,6 +60,7 @@ static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
 	struct onsend_info onsnd_info;
 	int ret;
 	struct run_act_ctx ra_ctx;
+	int backup_route_type;
 	
 	ret=1;
 	if (onsend_rt.rlist[DEFAULT_RT]){
@@ -68,9 +69,11 @@ static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
 		onsnd_info.buf=buf;
 		onsnd_info.len=len;
 		p_onsend=&onsnd_info;
+		backup_route_type=get_route_type();
 		set_route_type(ONSEND_ROUTE);
 		init_run_actions_ctx(&ra_ctx);
 		ret=run_actions(&ra_ctx, onsend_rt.rlist[DEFAULT_RT], orig_msg);
+		set_route_type(backup_route_type);
 		p_onsend=0; /* reset it */
 	}
 	return ret;

+ 2 - 0
route.h

@@ -66,6 +66,8 @@ extern int route_type;
 		route_type = (type); \
 	} while(0)
 
+#define get_route_type()	route_type
+
 #define is_route_type(type) (route_type == (type))
 
 struct route_list{