From fb131bbd34d7bd40298095433a308f38e49b3e77 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Thu, 14 Apr 2016 00:05:30 +0200 Subject: [PATCH] tm: implemented the execution of branch_route callback via kemi --- modules/tm/t_fwd.c | 21 +++++++++++++++++---- modules/tm/t_reply.c | 2 +- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/modules/tm/t_fwd.c b/modules/tm/t_fwd.c index 15f0969af1c..dc97ad97736 100644 --- a/modules/tm/t_fwd.c +++ b/modules/tm/t_fwd.c @@ -58,6 +58,7 @@ #include "../../dst_blacklist.h" #endif #include "../../atomic_ops.h" /* membar_depends() */ +#include "../../kemi.h" extern int tm_failure_exec_mode; @@ -152,6 +153,8 @@ static int prepare_new_uac( struct cell *t, struct sip_msg *i_req, struct socket_info *force_send_socket_bak; struct dest_info *dst; struct run_act_ctx ctx; + struct run_act_ctx *bctx; + sr_kemi_eng_t *keng; shbuf=0; ret=E_UNSPEC; @@ -340,10 +343,20 @@ static int prepare_new_uac( struct cell *t, struct sip_msg *i_req, /* set the new values */ i_req->fwd_send_flags=snd_flags /* intial value */; set_force_socket(i_req, fsocket); - if (run_top_route(branch_rt.rlist[branch_route], i_req, &ctx) - < 0) - { - LOG(L_DBG, "negative return code in run_top_route\n"); + keng = sr_kemi_eng_get(); + if(unlikely(keng!=NULL)) { + bctx = sr_kemi_act_ctx_get(); + sr_kemi_act_ctx_set(&ctx); + if(keng->froute(i_req, BRANCH_ROUTE, + sr_kemi_cbname_lookup_idx(branch_route))<0) { + LM_ERR("error running branch route kemi callback\n"); + } + sr_kemi_act_ctx_set(bctx); + } else { + if (run_top_route(branch_rt.rlist[branch_route], + i_req, &ctx) < 0) { + LOG(L_DBG, "negative return code in run_top_route\n"); + } } /* update dst send_flags and send socket*/ snd_flags=i_req->fwd_send_flags; diff --git a/modules/tm/t_reply.c b/modules/tm/t_reply.c index 237c38bfdf5..6022d50a675 100644 --- a/modules/tm/t_reply.c +++ b/modules/tm/t_reply.c @@ -993,7 +993,7 @@ int run_failure_handlers(struct cell *t, struct sip_msg *rpl, if(unlikely(keng!=NULL)) { if(keng->froute(&faked_req, FAILURE_ROUTE, sr_kemi_cbname_lookup_idx(on_failure))<0) { - LM_ERR("error running failure kemi callback\n"); + LM_ERR("error running failure route kemi callback\n"); } } else { if (run_top_route(failure_rt.rlist[on_failure], &faked_req, 0)<0)