Skip to content

Commit

Permalink
db_mysql: init libssl in a thread
Browse files Browse the repository at this point in the history
  • Loading branch information
space88man committed Jan 29, 2024
1 parent 2611a46 commit 5dffb93
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/modules/db_mysql/km_dbase.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand All @@ -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
Expand Down

0 comments on commit 5dffb93

Please sign in to comment.