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-46:

cleanup of my_win_init(), removed setlocale and server specific stuff
This commit is contained in:
holzboote@googlemail.com
2013-08-14 16:08:21 +02:00
parent 1182179b5c
commit bb809b33fc
2 changed files with 6 additions and 59 deletions

View File

@@ -84,16 +84,15 @@ void my_init(void)
DBUG_PROCESS(my_progname ? my_progname : (char*) "unknown"); DBUG_PROCESS(my_progname ? my_progname : (char*) "unknown");
if (!home_dir) if (!home_dir)
{ /* Don't initialize twice */ { /* Don't initialize twice */
my_win_init();
if ((home_dir=getenv("HOME")) != 0) if ((home_dir=getenv("HOME")) != 0)
home_dir=intern_filename(home_dir_buff,home_dir); home_dir=intern_filename(home_dir_buff,home_dir);
#ifndef VMS #ifndef VMS
/* Default creation of new files */ /* Default creation of new files */
if ((str=getenv("UMASK")) != 0) if ((str=getenv("UMASK")) != 0)
my_umask=(int) (atoi_octal(str) | 0600); my_umask=(int) (atoi_octal(str) | 0600);
/* Default creation of new dir's */ /* Default creation of new dir's */
if ((str=getenv("UMASK_DIR")) != 0) if ((str=getenv("UMASK_DIR")) != 0)
my_umask_dir=(int) (atoi_octal(str) | 0700); my_umask_dir=(int) (atoi_octal(str) | 0700);
#endif #endif
#ifdef VMS #ifdef VMS
init_ctype(); /* Stupid linker don't link _ctype.c */ init_ctype(); /* Stupid linker don't link _ctype.c */
@@ -101,7 +100,7 @@ void my_init(void)
DBUG_PRINT("exit",("home: '%s'",home_dir)); DBUG_PRINT("exit",("home: '%s'",home_dir));
} }
#ifdef _WIN32 #ifdef _WIN32
win32_init_tcp_ip(); my_win_init();
#endif #endif
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
@@ -204,60 +203,8 @@ void setEnvString(char *ret, const char *name, const char *value)
static void my_win_init(void) static void my_win_init(void)
{ {
HKEY hSoftMysql ;
DWORD dimName = 256 ;
DWORD dimData = 1024 ;
DWORD dimNameValueBuffer = 256 ;
DWORD dimDataValueBuffer = 1024 ;
DWORD indexValue = 0 ;
long retCodeEnumValue ;
char NameValueBuffer[256] ;
char DataValueBuffer[1024] ;
char EnvString[1271] ;
const char *targetKey = "Software\\MySQL" ;
DBUG_ENTER("my_win_init"); DBUG_ENTER("my_win_init");
win32_init_tcp_ip();
setlocale(LC_CTYPE, ""); /* To get right sortorder */
/* Clear the OS system variable TZ and avoid the 100% CPU usage */
_putenv( "TZ=" );
_tzset();
/* apre la chiave HKEY_LOCAL_MACHINES\software\MySQL */
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE,(LPCTSTR)targetKey,0,
KEY_READ,&hSoftMysql) != ERROR_SUCCESS)
DBUG_VOID_RETURN;
/*
** Ne legge i valori e li inserisce nell'ambiente
** suppone che tutti i valori letti siano di tipo stringa + '\0'
** Legge il valore con indice 0 e lo scarta
*/
retCodeEnumValue = RegEnumValue(hSoftMysql, indexValue++,
(LPTSTR)NameValueBuffer, &dimNameValueBuffer,
NULL, NULL, (LPBYTE)DataValueBuffer,
&dimDataValueBuffer) ;
while (retCodeEnumValue != ERROR_NO_MORE_ITEMS)
{
char *my_env;
/* Crea la stringa d'ambiente */
setEnvString(EnvString, NameValueBuffer, DataValueBuffer) ;
my_env=strdup(EnvString); /* variable for putenv must be allocated ! */
putenv(my_env) ;
dimNameValueBuffer = dimName ;
dimDataValueBuffer = dimData ;
retCodeEnumValue = RegEnumValue(hSoftMysql, indexValue++,
NameValueBuffer, &dimNameValueBuffer,
NULL, NULL, (LPBYTE)DataValueBuffer,
&dimDataValueBuffer) ;
}
/* chiude la chiave */
RegCloseKey(hSoftMysql) ;
DBUG_VOID_RETURN ; DBUG_VOID_RETURN ;
} }

View File

@@ -119,9 +119,9 @@ DWORD WINAPI thread_conc27(void)
{ {
MYSQL *mysql; MYSQL *mysql;
int rc; int rc;
MYSQL_RES *res;
mysql_thread_init(); mysql_thread_init();
mysql= mysql_init(NULL); mysql= mysql_init(NULL);
MYSQL_RES *res;
if(!mysql_real_connect(mysql, hostname, username, password, schema, if(!mysql_real_connect(mysql, hostname, username, password, schema,
port, socketname, 0)) port, socketname, 0))
{ {