Skip to content

Commit

Permalink
Fixed - rcl_release_url() was never called in some cases
Browse files Browse the repository at this point in the history
  • Loading branch information
ar45 committed Sep 11, 2024
1 parent 377d72b commit 50d1efb
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions modules/rest_client/rest_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ int async_rest_method(enum rest_client_method method, struct sip_msg *msg,

/* keep default async status of NO_IO */
pkg_free(param);
return rc;
goto done;

/* no need for async - transfer already completed! */
} else if (read_fd == ASYNC_SYNC) {
Expand All @@ -646,22 +646,25 @@ int async_rest_method(enum rest_client_method method, struct sip_msg *msg,
val.ri = (int)http_rc;
if (pv_set_value(msg, (pv_spec_p)code_pv, 0, &val) != 0) {
LM_ERR("failed to set output code pv\n");
return RCL_INTERNAL_ERR;
rc = RCL_INTERNAL_ERR;
goto done;
}
}

val.flags = PV_VAL_STR;
val.rs = param->body;
if (pv_set_value(msg, (pv_spec_p)body_pv, 0, &val) != 0) {
LM_ERR("failed to set output body pv\n");
return RCL_INTERNAL_ERR;
rc = RCL_INTERNAL_ERR;
goto done;
}

if (ctype_pv) {
val.rs = param->ctype;
if (pv_set_value(msg, (pv_spec_p)ctype_pv, 0, &val) != 0) {
LM_ERR("failed to set output ctype pv\n");
return RCL_INTERNAL_ERR;
rc = RCL_INTERNAL_ERR;
goto done;
}
}

Expand All @@ -672,7 +675,7 @@ int async_rest_method(enum rest_client_method method, struct sip_msg *msg,
pkg_free(param);

async_status = ASYNC_SYNC;
return rc;
goto done;
}

/* the TCP connection is established, async started with success */
Expand All @@ -692,6 +695,11 @@ int async_rest_method(enum rest_client_method method, struct sip_msg *msg,

async_status = read_fd;
return 1;

done:
if (lrc == RCL_OK_LOCKED)
rcl_release_url(host, rc == RCL_OK);
return rc;
}

static int w_async_rest_get(struct sip_msg *msg, async_ctx *ctx, str *url,
Expand Down

0 comments on commit 50d1efb

Please sign in to comment.