Browse code

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 authored on 03/06/2009 08:38:42
Showing 4 changed files
... ...
@@ -151,6 +151,7 @@ static char *print_uac_request( struct cell *t, struct sip_msg *i_req,
151 151
 	struct sip_uri parsed_uri_bak;
152 152
 	int parsed_uri_ok_bak, uri_backed_up;
153 153
 	str msg_uri_bak;
154
+	int backup_route_type;
154 155
 
155 156
 	shbuf=0;
156 157
 	msg_uri_bak.s=0; /* kill warnings */
... ...
@@ -189,12 +190,14 @@ static char *print_uac_request( struct cell *t, struct sip_msg *i_req,
189 189
 
190 190
 	if (unlikely(branch_route)) {
191 191
 		     /* run branch_route actions if provided */
192
+		backup_route_type = get_route_type();
192 193
 		set_route_type(BRANCH_ROUTE);
193 194
 		tm_ctx_set_branch_index(branch+1);
194 195
 		if (run_top_route(branch_rt.rlist[branch_route], i_req) < 0) {
195 196
 			LOG(L_ERR, "ERROR: print_uac_request: Error in run_top_route\n");
196 197
 		}
197 198
 		tm_ctx_set_branch_index(0);
199
+		set_route_type(backup_route_type);
198 200
 	}
199 201
 
200 202
 	/* run the specific callbacks for this transaction */
... ...
@@ -182,7 +182,7 @@ static int child_init(int rank)
182 182
 		if(faked_msg_init()<0)
183 183
 			return -1;
184 184
 		fmsg = faked_msg_next();
185
-		rtb = route_type;
185
+		rtb = get_route_type();
186 186
 		set_route_type(REQUEST_ROUTE);
187 187
 		run_top_route(event_rt.rlist[rt], fmsg);
188 188
 		set_route_type(rtb);
... ...
@@ -60,6 +60,7 @@ static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
60 60
 	struct onsend_info onsnd_info;
61 61
 	int ret;
62 62
 	struct run_act_ctx ra_ctx;
63
+	int backup_route_type;
63 64
 	
64 65
 	ret=1;
65 66
 	if (onsend_rt.rlist[DEFAULT_RT]){
... ...
@@ -68,9 +69,11 @@ static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
68 68
 		onsnd_info.buf=buf;
69 69
 		onsnd_info.len=len;
70 70
 		p_onsend=&onsnd_info;
71
+		backup_route_type=get_route_type();
71 72
 		set_route_type(ONSEND_ROUTE);
72 73
 		init_run_actions_ctx(&ra_ctx);
73 74
 		ret=run_actions(&ra_ctx, onsend_rt.rlist[DEFAULT_RT], orig_msg);
75
+		set_route_type(backup_route_type);
74 76
 		p_onsend=0; /* reset it */
75 77
 	}
76 78
 	return ret;
... ...
@@ -66,6 +66,8 @@ extern int route_type;
66 66
 		route_type = (type); \
67 67
 	} while(0)
68 68
 
69
+#define get_route_type()	route_type
70
+
69 71
 #define is_route_type(type) (route_type == (type))
70 72
 
71 73
 struct route_list{