Skip to content
Permalink
Browse files

rest_client: Explicitly set retcode_pv to 0 on error

This avoids any scripting mistakes where:

    * the user does not init $var(http_rc) to 0 prior to rest_get()
    * rest_get() fails (e.g. connection timeout -- web server is down)
    * $var(http_rc) is untouched, yet mistakenly holds 200 from a
      previous (successful) run of the same process
  • Loading branch information
liviuchircu committed Mar 14, 2019
1 parent 320e412 commit 9e842178d6c3d96143f4d1881bb57cdd180153f6
Showing with 7 additions and 0 deletions.
  1. +7 −0 modules/rest_client/rest_client.c
@@ -514,6 +514,13 @@ int async_rest_method(enum rest_client_method method, struct sip_msg *msg,
if (read_fd == ASYNC_NO_IO) {
ctx->resume_param = NULL;
ctx->resume_f = NULL;
if (code_pv) {
val.flags = PV_VAL_INT|PV_TYPE_INT;
val.ri = 0;
if (pv_set_value(msg, (pv_spec_p)code_pv, 0, &val) != 0)
LM_ERR("failed to set output code pv\n");
}

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

0 comments on commit 9e84217

Please sign in to comment.
You can’t perform that action at this time.