Module: sip-router Branch: master Commit: 593513f8e03096319dc0ec4f2fa9752e31b0686c URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=593513f8...
Author: Miklos Tirpak miklos@iptel.org Committer: Miklos Tirpak miklos@iptel.org Date: Wed Jun 3 10:38:42 2009 +0200
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.
---
modules/tm/t_fwd.c | 3 +++ modules_k/htable/htable.c | 2 +- onsend.h | 3 +++ route.h | 2 ++ 4 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/modules/tm/t_fwd.c b/modules/tm/t_fwd.c index 01a3699..f62af1f 100644 --- a/modules/tm/t_fwd.c +++ b/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 */ diff --git a/modules_k/htable/htable.c b/modules_k/htable/htable.c index 68c3e2f..2f75738 100644 --- a/modules_k/htable/htable.c +++ b/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); diff --git a/onsend.h b/onsend.h index ffec9f2..93f6dca 100644 --- a/onsend.h +++ b/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; diff --git a/route.h b/route.h index 6232f4b..e346ebd 100644 --- a/route.h +++ b/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{