diff --git a/libmariadb/mariadb_lib.c b/libmariadb/mariadb_lib.c index 9265532e..9a9c3495 100644 --- a/libmariadb/mariadb_lib.c +++ b/libmariadb/mariadb_lib.c @@ -1802,8 +1802,10 @@ static void mysql_close_memory(MYSQL *mysql) free(mysql->user); free(mysql->passwd); free(mysql->db); + free(mysql->unix_socket); free(mysql->server_version); - mysql->host_info= mysql->host= mysql->server_version=mysql->user=mysql->passwd=mysql->db=0; + mysql->host_info= mysql->host= mysql->unix_socket= + mysql->server_version=mysql->user=mysql->passwd=mysql->db=0; } void my_set_error(MYSQL *mysql, @@ -3421,12 +3423,22 @@ const char * STDCALL mysql_sqlstate(MYSQL *mysql) return mysql->net.sqlstate; } +#ifdef _WIN32 static int mysql_once_init() +#else +static void mysql_once_init() +#endif { ma_init(); /* Will init threads */ init_client_errs(); if (mysql_client_plugin_init()) + { +#ifdef _WIN32 return 1; +#else + return; +#endif + } if (!mysql_port) { struct servent *serv_ptr; @@ -3453,7 +3465,9 @@ static int mysql_once_init() if (!mysql_ps_subsystem_initialized) mysql_init_ps_subsystem(); mysql_client_init = 1; +#ifdef _WIN32 return 0; +#endif } #ifdef _WIN32 diff --git a/unittest/libmariadb/CMakeLists.txt b/unittest/libmariadb/CMakeLists.txt index f4d69012..79a1ccc5 100644 --- a/unittest/libmariadb/CMakeLists.txt +++ b/unittest/libmariadb/CMakeLists.txt @@ -34,7 +34,7 @@ ENDIF() SET(API_TESTS ${API_TESTS} "async") #exclude following tests from ctests, since we need to run them maually with different credentials -SET(MANUAL_TESTS "t_aurora") +SET(MANUAL_TESTS "t_aurora" "t_conc173") # Get finger print from server certificate IF(WITH_SSL) IF(OPENSSL_FOUND) diff --git a/unittest/libmariadb/connection.c b/unittest/libmariadb/connection.c index 0169d76c..33f0f691 100644 --- a/unittest/libmariadb/connection.c +++ b/unittest/libmariadb/connection.c @@ -52,7 +52,7 @@ static int test_conc66(MYSQL *my) rc= mysql_options(mysql, MYSQL_READ_DEFAULT_FILE, "./my.cnf"); check_mysql_rc(rc, mysql); - sprintf(query, "GRANT ALL ON %s.* TO 'conc66'@'%s' IDENTIFIED BY 'test\";#test'", schema, hostname); + sprintf(query, "GRANT ALL ON %s.* TO 'conc66'@'%s' IDENTIFIED BY 'test\";#test'", schema, hostname ? hostname : "localhost"); rc= mysql_query(my, query); check_mysql_rc(rc, my); rc= mysql_query(my, "FLUSH PRIVILEGES"); @@ -64,7 +64,7 @@ static int test_conc66(MYSQL *my) return FAIL; } - sprintf(query, "DROP user conc66@%s", hostname); + sprintf(query, "DROP user conc66@%s", hostname ? hostname : "localhost"); rc= mysql_query(my, query); check_mysql_rc(rc, my); diff --git a/unittest/libmariadb/t_conc173.c b/unittest/libmariadb/t_conc173.c new file mode 100644 index 00000000..7d3474e8 --- /dev/null +++ b/unittest/libmariadb/t_conc173.c @@ -0,0 +1,72 @@ +/* +Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved. + +The MySQL Connector/C is licensed under the terms of the GPLv2 +, like most +MySQL Connectors. There are special exceptions to the terms and +conditions of the GPLv2 as it is applied to this software, see the +FLOSS License Exception +. + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published +by the Free Software Foundation; version 2 of the License. + +This program is distributed in the hope that it will be useful, but +WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +for more details. + +You should have received a copy of the GNU General Public License along +with this program; if not, write to the Free Software Foundation, Inc., +51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ +/** + Some basic tests of the client API. +*/ + +#include "my_test.h" + +static int test_conc_173(MYSQL *my) +{ + MYSQL mysql; + int arg; + int i=0; + + for (;;) + { + mysql_init(&mysql); + mysql_options(&mysql, MYSQL_READ_DEFAULT_GROUP, "client"); + mysql_options(&mysql, MYSQL_OPT_COMPRESS, 0); + + mysql_options(&mysql, MYSQL_OPT_NAMED_PIPE, 0); + + arg = MYSQL_PROTOCOL_SOCKET; + + mysql_options(&mysql, MYSQL_OPT_PROTOCOL, &arg); + + if(!mysql_real_connect(&mysql, hostname, username, password, schema, 0, 0, 0)) { + fprintf(stderr, "Failed to connect to database after %d iterations: Error: %s\n", i, mysql_error(&mysql)); + return 1; + } + mysql_close(&mysql); + } + return OK; +} + +struct my_tests_st my_tests[] = { + {"test_conc_173", test_conc_173, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, +}; + + +int main(int argc, char **argv) +{ + if (argc > 1) + get_options(argc, argv); + + get_envvars(); + + run_tests(my_tests); + + return(exit_status()); +}