From 272a4e08be61870cd7788c8cd8dd9be29b50753f Mon Sep 17 00:00:00 2001 From: S-P Chan Date: Tue, 27 Feb 2024 04:58:40 +0800 Subject: [PATCH] Revert 8b2573c1f7 - split into per module commits --- src/core/rthreads.h | 38 ---------------------- src/modules/http_async_client/http_multi.c | 6 +--- src/modules/http_client/http_client.c | 23 +++++-------- src/modules/xcap_client/xcap_client.c | 5 +-- 4 files changed, 11 insertions(+), 61 deletions(-) diff --git a/src/core/rthreads.h b/src/core/rthreads.h index 0f4f0cf8b8a..e96f45c9395 100644 --- a/src/core/rthreads.h +++ b/src/core/rthreads.h @@ -254,41 +254,3 @@ static int run_thread4P5I2P2(_thread_proto4P5I2P2 fn, void *arg1, void *arg2, #endif } #endif - -/* - * prototype: CURLcode curl_global_init(long flags) { ... } - */ -#ifdef KSR_RTHREAD_NEED_4L -typedef int (*_thread_proto4L)(long); -struct _thread_args4L -{ - _thread_proto4L fn; - long arg1; - int *ret; -}; -static void *run_thread_wrap4L(struct _thread_args4L *args) -{ - *args->ret = (*args->fn)(args->arg1); - return NULL; -} - -static int run_thread4L(_thread_proto4L fn, long arg1) -{ -#ifdef USE_TLS - pthread_t tid; - int ret; - - if(likely(ksr_tls_threads_mode == 0 - || (ksr_tls_threads_mode == 1 && process_no > 0))) { - return fn(arg1); - } - pthread_create(&tid, NULL, (_thread_proto)run_thread_wrap4L, - &(struct _thread_args4L){fn, arg1, &ret}); - pthread_join(tid, NULL); - - return ret; -#else - return fn(arg1) -#endif -} -#endif diff --git a/src/modules/http_async_client/http_multi.c b/src/modules/http_async_client/http_multi.c index a0ee1c877cf..a57aba9c951 100644 --- a/src/modules/http_async_client/http_multi.c +++ b/src/modules/http_async_client/http_multi.c @@ -32,9 +32,6 @@ #include "../../core/mem/mem.h" #include "../../core/ut.h" #include "../../core/hashes.h" -#define KSR_RTHREAD_NEED_4L -#define KSR_RTHREAD_SKIP_P -#include "../../core/rthreads.h" #include "http_multi.h" extern int hash_size; @@ -392,8 +389,7 @@ void set_curl_mem_callbacks(void) break; case 1: LM_DBG("Initilizing cURL with sys malloc\n"); - rc = run_thread4L( - (_thread_proto4L)curl_global_init, CURL_GLOBAL_ALL); + rc = curl_global_init(CURL_GLOBAL_ALL); if(rc != 0) { LM_ERR("Cannot initialize cURL: %d\n", rc); } diff --git a/src/modules/http_client/http_client.c b/src/modules/http_client/http_client.c index ca605ec1729..48844246984 100644 --- a/src/modules/http_client/http_client.c +++ b/src/modules/http_client/http_client.c @@ -64,9 +64,6 @@ #include "../../core/lvalue.h" #include "../../core/pt.h" /* Process table */ #include "../../core/kemi.h" -#define KSR_RTHREAD_NEED_4L -#define KSR_RTHREAD_SKIP_P -#include "../../core/rthreads.h" #include "functions.h" #include "curlcon.h" @@ -79,10 +76,8 @@ MODULE_VERSION #define CURL_USER_AGENT_LEN (sizeof(CURL_USER_AGENT) - 1) /* Module parameter variables */ -unsigned int default_connection_timeout = - 0; /*!< 0 = not user configured - the default (4 seconds) will be used */ -unsigned int timeout_mode = - 1; /*!< 0 = timeout disabled, 1 (default) = timeout in seconds, 2 = timeout in ms */ +unsigned int default_connection_timeout = 0; /*!< 0 = not user configured - the default (4 seconds) will be used */ +unsigned int timeout_mode = 1; /*!< 0 = timeout disabled, 1 (default) = timeout in seconds, 2 = timeout in ms */ char *default_tls_cacert = NULL; /*!< File name: Default CA cert to use for curl TLS connection */ str default_tls_clientcert = @@ -285,7 +280,7 @@ static int mod_init(void) LM_DBG("init curl module\n"); /* Initialize curl */ - if(run_thread4L((_thread_proto4L)&curl_global_init, CURL_GLOBAL_ALL)) { + if(curl_global_init(CURL_GLOBAL_ALL)) { LM_ERR("curl_global_init failed\n"); return -1; } @@ -322,16 +317,16 @@ static int mod_init(void) * - 1 (default) : timeout value is in seconds. * - 2 : timeout value is in milliseconds. */ - if(!(timeout_mode == 1 || timeout_mode == 2)) { - if(default_connection_timeout > 0) { + if (!(timeout_mode == 1 || timeout_mode == 2)) { + if (default_connection_timeout > 0) { LM_WARN("configured connection_timeout is ignored " - "because timeouts are disabled (timeout_mode)\n"); + "because timeouts are disabled (timeout_mode)\n"); } - } else if(default_connection_timeout == 0) { + } else if (default_connection_timeout == 0) { LM_INFO("curl connection timeout set to zero. Using default 4 secs\n"); - if(timeout_mode == 1) { /* timeout is in seconds (default) */ + if (timeout_mode == 1) { /* timeout is in seconds (default) */ default_connection_timeout = 4; - } else if(timeout_mode == 2) { /* timeout is in milliseconds */ + } else if (timeout_mode == 2) { /* timeout is in milliseconds */ default_connection_timeout = 4000; } } diff --git a/src/modules/xcap_client/xcap_client.c b/src/modules/xcap_client/xcap_client.c index 4de2d367b63..ac77228bfde 100644 --- a/src/modules/xcap_client/xcap_client.c +++ b/src/modules/xcap_client/xcap_client.c @@ -41,9 +41,6 @@ #include "../../core/mem/shm_mem.h" #include "../../core/rpc.h" #include "../../core/rpc_lookup.h" -#define KSR_RTHREAD_NEED_4L -#define KSR_RTHREAD_SKIP_P -#include "../../core/rthreads.h" #include "../presence/utils_func.h" #include "xcap_functions.h" #include "xcap_client.h" @@ -143,7 +140,7 @@ static int mod_init(void) xcap_dbf.close(xcap_db); xcap_db = NULL; - run_thread4L((_thread_proto4L)curl_global_init, CURL_GLOBAL_ALL); + curl_global_init(CURL_GLOBAL_ALL); if(periodical_query) { register_timer(query_xcap_update, 0, query_period);