Skip to content

Commit

Permalink
[async] fix async launching without report route
Browse files Browse the repository at this point in the history
Handle the case where no report route is provided.
Closes #3188

(cherry picked from commit 26d6d95)
  • Loading branch information
bogdan-iancu committed Oct 9, 2023
1 parent fd06576 commit 47f56e0
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions async.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ int async_script_launch(struct sip_msg *msg, struct action* a,
return -1;
}

if ( (ctx=shm_malloc(sizeof(async_launch_ctx) + (report_route_param?report_route_param->len:0)))==NULL) {
if ( (ctx=shm_malloc(sizeof(async_launch_ctx) + ( (report_route&&report_route_param)?report_route_param->len:0)))==NULL) {
LM_ERR("failed to allocate new ctx, forcing sync mode\n");
return -1;
}
Expand Down Expand Up @@ -339,20 +339,22 @@ int async_script_launch(struct sip_msg *msg, struct action* a,

/* ctx is to be used from this point further */

ctx->report_route = dup_ref_script_route_in_shm( report_route, 0);
if (!ref_script_route_is_valid(ctx->report_route)) {
LM_ERR("failed dup resume route -> act in sync mode\n");
goto sync;
}
if (report_route) {
ctx->report_route = dup_ref_script_route_in_shm( report_route, 0);
if (!ref_script_route_is_valid(ctx->report_route)) {
LM_ERR("failed dup resume route -> act in sync mode\n");
goto sync;
}

if (report_route_param) {
ctx->report_route_param.s = (char *)(ctx+1);
ctx->report_route_param.len = report_route_param->len;
memcpy(ctx->report_route_param.s, report_route_param->s,
report_route_param->len);
} else {
ctx->report_route_param.s = NULL;
ctx->report_route_param.len = 0;
if (report_route_param) {
ctx->report_route_param.s = (char *)(ctx+1);
ctx->report_route_param.len = report_route_param->len;
memcpy(ctx->report_route_param.s, report_route_param->s,
report_route_param->len);
} else {
ctx->report_route_param.s = NULL;
ctx->report_route_param.len = 0;
}
}

if (async_status!=ASYNC_NO_FD) {
Expand Down

0 comments on commit 47f56e0

Please sign in to comment.