From 2611a4670c65dd32fc1daf6b67e37852936ba69c Mon Sep 17 00:00:00 2001 From: S-P Chan Date: Sun, 28 Jan 2024 07:38:16 +0800 Subject: [PATCH] db_unixodbc: init libssl in a thread --- src/modules/db_unixodbc/dbase.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/modules/db_unixodbc/dbase.c b/src/modules/db_unixodbc/dbase.c index eb02b29de50..f3c01b81ee5 100644 --- a/src/modules/db_unixodbc/dbase.c +++ b/src/modules/db_unixodbc/dbase.c @@ -22,7 +22,7 @@ * */ - +#include #include "../../core/mem/mem.h" #include "../../core/dprint.h" #include "../../core/async_task.h" @@ -227,8 +227,10 @@ extern char *db_unixodbc_tquote; /* * Initialize database module * No function should be called before this + * + * Init libssl in a thread */ -db1_con_t *db_unixodbc_init(const str *_url) +static db1_con_t *db_unixodbc_init0(const str *_url) { db1_con_t *c; c = db_do_init(_url, (void *)db_unixodbc_new_connection); @@ -237,6 +239,18 @@ db1_con_t *db_unixodbc_init(const str *_url) return c; } +db1_con_t *db_unixodbc_init(const str *_url) +{ + pthread_t tid; + db1_con_t *ret; + + pthread_create( + &tid, NULL, (void *(*)(void *))db_unixodbc_init0, (void *)_url); + pthread_join(tid, (void **)&ret); + + return ret; +} + /* * Shut down database module * No function should be called after this