Quellcode durchsuchen

db_unixodbc: init libssl in a thread

S-P Chan vor 1 Jahr
Ursprung
Commit
2611a4670c
1 geänderte Dateien mit 16 neuen und 2 gelöschten Zeilen
  1. 16 2
      src/modules/db_unixodbc/dbase.c

+ 16 - 2
src/modules/db_unixodbc/dbase.c

@@ -22,7 +22,7 @@
  *
  */
 
-
+#include <pthread.h>
 #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