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
  • Loading branch information
bogdan-iancu committed Apr 3, 2018
1 parent bc4e6cb commit 7a821af
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions modules/tm/async.c
Expand Up @@ -57,12 +57,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 @@ -177,7 +179,7 @@ int t_resume_async(int *fd, void *param)

/* 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 @@ -251,7 +253,7 @@ int t_handle_async(struct sip_msg *msg, struct action* a , int resume_route)
goto failure;
}

async_status = ASYNC_NO_IO; /*assume defauly status "no IO done" */
async_status = ASYNC_NO_IO; /*assume default status "no IO done" */
return_code = ((acmd_export_t*)(a->elem[0].u.data))->function(msg,
(async_ctx*)ctx,
(char*)a->elem[1].u.data, (char*)a->elem[2].u.data,
Expand Down Expand Up @@ -348,7 +350,7 @@ int t_handle_async(struct sip_msg *msg, struct action* a , int resume_route)
/* get rid of the context, useless at this point further */
shm_free(ctx);
/* 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 @@ -360,7 +362,7 @@ int t_handle_async(struct sip_msg *msg, struct action* a , int resume_route)
/* get rid of the context, useless at this point further */
if (ctx) shm_free(ctx);
/* 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 7a821af

Please sign in to comment.