diff --git a/action.c b/action.c index fad85bfe55..f2c64727dd 100644 --- a/action.c +++ b/action.c @@ -1881,6 +1881,8 @@ int do_action(struct action* a, struct sip_msg* msg) msg, a->file, a->line) ; ret = async_start_f( msg, aitem, a->elem[1].u.number); } + action_flags |= ACT_FL_TBCONT; + ret = 0; break; case FORCE_RPORT_T: script_trace("core", "force_rport", msg, a->file, a->line) ; diff --git a/action.h b/action.h index 13c4585407..c0f9ad8e93 100644 --- a/action.h +++ b/action.h @@ -32,9 +32,10 @@ #include "parser/msg_parser.h" #include "route_struct.h" -#define ACT_FL_EXIT 1 -#define ACT_FL_RETURN 2 -#define ACT_FL_DROP 4 +#define ACT_FL_EXIT (1<<0) +#define ACT_FL_RETURN (1<<1) +#define ACT_FL_DROP (2<<2) +#define ACT_FL_TBCONT (2<<3) extern int action_flags; extern int use_script_trace; diff --git a/modules/tm/async.c b/modules/tm/async.c index 46a0bf9c08..a9de766d6f 100644 --- a/modules/tm/async.c +++ b/modules/tm/async.c @@ -41,6 +41,16 @@ typedef struct _async_ctx { extern int return_code; /* from action.c, return code */ + +static inline void run_resume_route( int resume_route, struct sip_msg *msg) +{ + /* run the resume route and if it ends the msg handling (no other aysnc + * started), run the post script callbacks. */ + if ( (run_top_route(rlist[resume_route].a, msg) & ACT_FL_TBCONT) == 0 ) + exec_post_req_cb(msg); +} + + /* function triggered from reactor in order to continue the processing */ int t_resume_async(int fd, void *param) @@ -92,7 +102,7 @@ int t_resume_async(int fd, void *param) close(fd); /* run the resume_route[] */ - run_top_route( rlist[ctx->resume_route].a, &faked_req); + run_resume_route( ctx->resume_route, &faked_req); restore: /* restore original environment */ @@ -176,8 +186,6 @@ int t_handle_async(struct sip_msg *msg, struct action* a , int resume_route) ctx->resume_route = resume_route; ctx->t = t; - set_kr(REQ_FWDED); - /* place the FD + resume function (as param) into reactor */ if (reactor_add_reader( fd, F_SCRIPT_ASYNC, (void*)ctx)<0 ) { LM_ERR("failed to add async FD to reactor -> act in sync mode\n"); @@ -193,7 +201,7 @@ int t_handle_async(struct sip_msg *msg, struct action* a , int resume_route) /* run the resume function */ ctx_f( fd, msg, ctx_p ); /* run the resume route in sync mode */ - run_top_route(rlist[resume_route].a, msg); + run_resume_route( resume_route, msg); /* break original script */ return 0; @@ -202,7 +210,7 @@ int t_handle_async(struct sip_msg *msg, struct action* a , int resume_route) /* execute here the resume route with failure indication */ return_code = -1; /* FIXME */ /* run the resume route */ - run_top_route(rlist[resume_route].a, msg); + run_resume_route( resume_route, msg); /* the triggering route is terminated and whole script ended */ return 0; }