1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-08 14:02:17 +03:00

Fix for CONC-336:

Allow multiple initialization of the client library (mysql_server_init(
mysql_server_end).
Note: This was already fixed by commit for CONC-277, unfortunately the fix
was overwritten by a bad merge.
This commit is contained in:
Georg Richter
2018-05-29 17:46:47 +02:00
parent 2a5f40fc82
commit 6b16eb778f
2 changed files with 9 additions and 3 deletions

View File

@@ -3532,6 +3532,7 @@ static void mysql_once_init()
}
#ifdef _WIN32
static INIT_ONCE init_once = (INIT_ONCE)INIT_ONCE_STATIC_INIT;
BOOL CALLBACK win_init_once(
PINIT_ONCE InitOnce,
PVOID Parameter,
@@ -3540,6 +3541,8 @@ BOOL CALLBACK win_init_once(
return !mysql_once_init();
return TRUE;
}
#else
static pthread_once_t init_once = PTHREAD_ONCE_INIT;
#endif
int STDCALL mysql_server_init(int argc __attribute__((unused)),
@@ -3547,11 +3550,9 @@ int STDCALL mysql_server_init(int argc __attribute__((unused)),
char **groups __attribute__((unused)))
{
#ifdef _WIN32
static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
BOOL ret = InitOnceExecuteOnce(&init_once, win_init_once, NULL, NULL);
return ret? 0: 1;
#else
static pthread_once_t init_once = PTHREAD_ONCE_INIT;
return pthread_once(&init_once, mysql_once_init);
#endif
}
@@ -3572,6 +3573,11 @@ void STDCALL mysql_server_end(void)
#endif
mysql_client_init= 0;
ma_init_done= 0;
#ifdef WIN32
init_once = (INIT_ONCE)INIT_ONCE_STATIC_INIT;
#else
init_once = (pthread_once_t)PTHREAD_ONCE_INIT;
#endif
}
my_bool STDCALL mysql_thread_init(void)

View File

@@ -26,7 +26,7 @@ INCLUDE_DIRECTORIES(${CC_SOURCE_DIR}/include
${CC_SOURCE_DIR}/unittest/libmariadb)
ADD_DEFINITIONS(-DLIBMARIADB)
SET(API_TESTS "bulk1" "performance" "basic-t" "fetch" "charset" "logs" "cursor" "errors" "view" "ps" "ps_bugs" "sp" "result" "connection" "misc" "ps_new" "thread" "features-10_2" "bulk1")
SET(API_TESTS "conc336" "bulk1" "performance" "basic-t" "fetch" "charset" "logs" "cursor" "errors" "view" "ps" "ps_bugs" "sp" "result" "connection" "misc" "ps_new" "thread" "features-10_2" "bulk1")
IF(WITH_DYNCOL)
SET(API_TESTS ${API_TESTS} "dyncol")
ENDIF()