From b15bc4451fc2a04d5896aa75d11d497e6366cd58 Mon Sep 17 00:00:00 2001 From: Liviu Chircu Date: Thu, 12 Sep 2024 10:40:56 +0300 Subject: [PATCH] rest_client: Complete the fix in a3dd31ad6 Proper pointer/data management. Credits to Aron Podrigal (@ar45) for providing feedback and testing! --- modules/rest_client/rest_methods.c | 8 ++++---- modules/rest_client/rest_methods.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/modules/rest_client/rest_methods.c b/modules/rest_client/rest_methods.c index 0bdac16d987..2febdb51a42 100644 --- a/modules/rest_client/rest_methods.c +++ b/modules/rest_client/rest_methods.c @@ -92,7 +92,7 @@ static int multi_pool_sz; static map_t rcl_connections; static gen_hash_t *rcl_parallel_connects; int no_concurrent_connects; -int curl_conn_lifetime; +unsigned int curl_conn_lifetime; static inline int rest_trace_enabled(void); static int trace_rest_message( rest_trace_param_t* tparam ); @@ -581,7 +581,7 @@ int rcl_acquire_url(const char *url, char **url_host) } if (*connected_ts != 0 && (get_ticks() - - (unsigned int)*(unsigned long *)(*connected_ts) < curl_conn_lifetime)) { + (unsigned int)*(unsigned long *)connected_ts < curl_conn_lifetime)) { new_connection = 0; } else { new_connection = 1; @@ -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) - *(unsigned long *)(*connected_ts) = (unsigned long)get_ticks(); + if (connected_ts) + *connected_ts = (void *)(unsigned long)get_ticks(); } pkg_free(url_host); diff --git a/modules/rest_client/rest_methods.h b/modules/rest_client/rest_methods.h index abf4546ee05..781d0f69f49 100644 --- a/modules/rest_client/rest_methods.h +++ b/modules/rest_client/rest_methods.h @@ -47,7 +47,7 @@ extern int ssl_verifyhost; extern int curl_http_version; extern int no_concurrent_connects; -extern int curl_conn_lifetime; +extern unsigned int curl_conn_lifetime; /* handle for use with synchronous reqs */ extern CURL *sync_handle;