mirror of https://github.com/sipwise/kamailio.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
88 lines
2.7 KiB
88 lines
2.7 KiB
From: S-P Chan <shihping.chan@gmail.com>
|
|
Date: Tue, 30 Jan 2024 14:07:11 +0800
|
|
Subject: outbound: init libssl in a thread
|
|
|
|
- use core/rthreads.h
|
|
- Xenial(OpenSSL < 1.1.1) fixes
|
|
|
|
From:
|
|
- 94f6df509bf77c19c745749716a9e075ec17f3c7
|
|
- 8bdd9ca4b3c3d4f9f2f201b0a9e0ad9a61eee41d
|
|
---
|
|
src/modules/outbound/outbound_mod.c | 44 ++++++++++++++++++-------------------
|
|
1 file changed, 22 insertions(+), 22 deletions(-)
|
|
|
|
diff --git a/src/modules/outbound/outbound_mod.c b/src/modules/outbound/outbound_mod.c
|
|
index e2e3a86..e5ed171 100644
|
|
--- a/src/modules/outbound/outbound_mod.c
|
|
+++ b/src/modules/outbound/outbound_mod.c
|
|
@@ -40,6 +40,10 @@
|
|
#include "../../core/parser/parse_uri.h"
|
|
#include "../../core/parser/parse_supported.h"
|
|
|
|
+#define KSR_RTHREAD_SKIP_P
|
|
+#define KSR_RTHREAD_NEED_V
|
|
+#include "../../core/rthreads.h"
|
|
+
|
|
#include "api.h"
|
|
#include "config.h"
|
|
|
|
@@ -75,26 +79,25 @@ struct module_exports exports = {
|
|
destroy /* destroy function */
|
|
};
|
|
|
|
-static void *mod_init_openssl(void *arg) {
|
|
- if(flow_token_secret.s) {
|
|
- assert(ob_key.len == SHA_DIGEST_LENGTH);
|
|
- LM_DBG("flow_token_secret mod param set. use persistent ob_key");
|
|
+static void mod_init_openssl(void)
|
|
+{
|
|
+ if(flow_token_secret.s) {
|
|
+ assert(ob_key.len == SHA_DIGEST_LENGTH);
|
|
+ LM_DBG("flow_token_secret mod param set. use persistent ob_key");
|
|
#if OPENSSL_VERSION_NUMBER < 0x030000000L
|
|
- SHA1((const unsigned char *)flow_token_secret.s, flow_token_secret.len,
|
|
- (unsigned char *)ob_key.s);
|
|
+ SHA1((const unsigned char *)flow_token_secret.s, flow_token_secret.len,
|
|
+ (unsigned char *)ob_key.s);
|
|
#else
|
|
- EVP_Q_digest(NULL, "SHA1", NULL, flow_token_secret.s,
|
|
- flow_token_secret.len, (unsigned char *)ob_key.s, NULL);
|
|
+ EVP_Q_digest(NULL, "SHA1", NULL, flow_token_secret.s,
|
|
+ flow_token_secret.len, (unsigned char *)ob_key.s, NULL);
|
|
#endif
|
|
- } else {
|
|
- if(RAND_bytes((unsigned char *)ob_key.s, ob_key.len) == 0) {
|
|
- LM_ERR("unable to get %d cryptographically strong pseudo-"
|
|
- "random bytes\n",
|
|
- ob_key.len);
|
|
- }
|
|
- }
|
|
-
|
|
- return NULL;
|
|
+ } else {
|
|
+ if(RAND_bytes((unsigned char *)ob_key.s, ob_key.len) == 0) {
|
|
+ LM_ERR("unable to get %d cryptographically strong pseudo-"
|
|
+ "random bytes\n",
|
|
+ ob_key.len);
|
|
+ }
|
|
+ }
|
|
}
|
|
|
|
static int mod_init(void)
|
|
@@ -116,12 +119,9 @@ static int mod_init(void)
|
|
ob_key.len = OB_KEY_LEN;
|
|
|
|
#if OPENSSL_VERSION_NUMBER < 0x010101000L
|
|
- mod_init_openssl(NULL);
|
|
+ mod_init_openssl();
|
|
#else
|
|
- pthread_t tid;
|
|
- void *retval;
|
|
- pthread_create(&tid, NULL, mod_init_openssl, NULL);
|
|
- pthread_join(tid, &retval);
|
|
+ run_threadV(mod_init_openssl);
|
|
#endif
|
|
|
|
if(cfg_declare("outbound", outbound_cfg_def, &default_outbound_cfg,
|