summaryrefslogtreecommitdiff
path: root/libmysql/libmysql.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmysql/libmysql.c')
-rw-r--r--libmysql/libmysql.c34
1 files changed, 14 insertions, 20 deletions
diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c
index 03c8436c13f..728454a50fb 100644
--- a/libmysql/libmysql.c
+++ b/libmysql/libmysql.c
@@ -96,24 +96,26 @@ static my_bool org_my_init_done= 0;
/*
- Initialize the MySQL library
+ Initialize the MySQL client library
SYNOPSIS
- mysql_once_init()
+ mysql_server_init()
NOTES
- Can't be static on NetWare
- This function is called by mysql_init() and indirectly called
- by mysql_query(), so one should never have to call this from an
- outside program.
+ Should be called before doing any other calls to the MySQL
+ client library to initialize thread specific variables etc.
+ It's called by mysql_init() to ensure that things will work for
+ old not threaded applications that doesn't call mysql_server_init()
+ directly.
RETURN
0 ok
1 could not initialize environment (out of memory or thread keys)
*/
-int mysql_once_init(void)
+int STDCALL mysql_server_init(int argc, char **argv, char **groups)
{
+ int result= 0;
if (!mysql_client_init)
{
mysql_client_init=1;
@@ -150,25 +152,19 @@ int mysql_once_init(void)
#if defined(SIGPIPE) && !defined(__WIN__)
(void) signal(SIGPIPE, SIG_IGN);
#endif
+ result= init_embedded_server(argc, argv, groups);
}
#ifdef THREAD
- else if (my_thread_init()) /* Init if new thread */
- return 1;
+ else
+ result= (int)my_thread_init(); /* Init if new thread */
#endif
- return 0;
+ return result;
}
-#ifndef EMBEDDED_LIBRARY
-int STDCALL mysql_server_init(int argc __attribute__((unused)),
- char **argv __attribute__((unused)),
- char **groups __attribute__((unused)))
-{
- return (int) mysql_once_init();
-}
-
void STDCALL mysql_server_end()
{
+ end_embedded_server();
/* If library called my_init(), free memory allocated by it */
if (!org_my_init_done)
{
@@ -183,8 +179,6 @@ void STDCALL mysql_server_end()
mysql_client_init= org_my_init_done= 0;
}
-#endif /*EMBEDDED_LIBRARY*/
-
my_bool STDCALL mysql_thread_init()
{
#ifdef THREAD