Module: kamailio
Branch: master
Commit: 5dffb934a2f7f986fdc09e433833991c54612646
URL:
https://github.com/kamailio/kamailio/commit/5dffb934a2f7f986fdc09e433833991…
Author: S-P Chan <shihping.chan(a)gmail.com>
Committer: S-P Chan <shihping.chan(a)gmail.com>
Date: 2024-01-30T06:51:36+08:00
db_mysql: init libssl in a thread
---
Modified: src/modules/db_mysql/km_dbase.c
---
Diff:
https://github.com/kamailio/kamailio/commit/5dffb934a2f7f986fdc09e433833991…
Patch:
https://github.com/kamailio/kamailio/commit/5dffb934a2f7f986fdc09e433833991…
---
diff --git a/src/modules/db_mysql/km_dbase.c b/src/modules/db_mysql/km_dbase.c
index 577f3dc798b..721ba8aa6cf 100644
--- a/src/modules/db_mysql/km_dbase.c
+++ b/src/modules/db_mysql/km_dbase.c
@@ -34,6 +34,7 @@
#include <stdio.h>
#include <string.h>
#include <mysql.h>
+#include <pthread.h>
#include <errmsg.h>
#include "../../core/mem/mem.h"
#include "../../core/dprint.h"
@@ -197,8 +198,10 @@ static char *db_mysql_tquote = "`";
* No function should be called before this
* \param _url URL used for initialization
* \return zero on success, negative value on failure
+ *
+ * Init libssl in a thread
*/
-db1_con_t *db_mysql_init(const str *_url)
+static db1_con_t *db_mysql_init0(const str *_url)
{
db1_con_t *c;
c = db_do_init(_url, (void *)db_mysql_new_connection);
@@ -208,6 +211,16 @@ db1_con_t *db_mysql_init(const str *_url)
}
+db1_con_t *db_mysql_init(const str *_url)
+{
+ pthread_t tid;
+ db1_con_t *ret;
+
+ pthread_create(&tid, NULL, (void *(*)(void *))db_mysql_init0, (void *)_url);
+ pthread_join(tid, (void **)&ret);
+
+ return ret;
+}
/**
* Shut down the database module.
* No function should be called after this