diff --git a/modules/rest_client/rest_client.c b/modules/rest_client/rest_client.c index 2b35440850a..22e4b5eed6f 100644 --- a/modules/rest_client/rest_client.c +++ b/modules/rest_client/rest_client.c @@ -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) { @@ -646,7 +646,8 @@ 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; } } @@ -654,14 +655,16 @@ int async_rest_method(enum rest_client_method method, struct sip_msg *msg, 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; } } @@ -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 */ @@ -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, diff --git a/modules/rest_client/rest_methods.c b/modules/rest_client/rest_methods.c index 8b3d20872f5..0bdac16d987 100644 --- a/modules/rest_client/rest_methods.c +++ b/modules/rest_client/rest_methods.c @@ -631,8 +631,8 @@ void rcl_release_url(char *url_host, int update_conn_ts) void **connected_ts; connected_ts = map_get(rcl_connections, host_str); - if (connected_ts) - *connected_ts = (void *)(unsigned long)get_ticks(); + if (connected_ts && *connected_ts) + *(unsigned long *)(*connected_ts) = (unsigned long)get_ticks(); } pkg_free(url_host);