Skip to content

Commit

Permalink
Fixed wrong triggering of post script callbacks.
Browse files Browse the repository at this point in the history
If the async() statement translates into a sync/inline operation as triggered from a non request route, do not trigger the post script callbacks.
Fix for #1312

(cherry picked from commit 7a821af)
  • Loading branch information
bogdan-iancu committed Apr 24, 2018
1 parent a11ef08 commit 03e24c2
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions modules/tm/async.c
Expand Up @@ -59,12 +59,14 @@ extern int return_code; /* from action.c, return code */



static inline void run_resume_route( int resume_route, struct sip_msg *msg)
static inline void run_resume_route( int resume_route, struct sip_msg *msg,
int run_post_cb)
{
/* 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);
if (run_post_cb)
exec_post_req_cb(msg);
}


Expand Down Expand Up @@ -166,7 +168,7 @@ int t_resume_async(int *fd, void *param)
route:
/* run the resume_route (some type as the original one) */
swap_route_type(route, ctx->route_type);
run_resume_route( ctx->resume_route, &faked_req);
run_resume_route( ctx->resume_route, &faked_req, 1);
set_route_type(route);

/* no need for the context anymore */
Expand Down Expand Up @@ -335,7 +337,7 @@ int t_handle_async(struct sip_msg *msg, struct action* a , int resume_route)
fd = return_code;
} while(async_status==ASYNC_CONTINUE||async_status==ASYNC_CHANGE_FD);
/* run the resume route in sync mode */
run_resume_route( resume_route, msg);
run_resume_route( resume_route, msg, (route_type!=REQUEST_ROUTE)?0:1);

/* break original script */
return 0;
Expand All @@ -345,7 +347,7 @@ int t_handle_async(struct sip_msg *msg, struct action* a , int resume_route)
return_code = -1;
resume:
/* run the resume route */
run_resume_route( resume_route, msg);
run_resume_route( resume_route, msg, (route_type!=REQUEST_ROUTE)?0:1);
/* the triggering route is terminated and whole script ended */
return 0;
}
Expand Down

0 comments on commit 03e24c2

Please sign in to comment.