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

if reconnecting fails (e.g. server has gone) we don't freee memory associated with tmp_mysql.
This commit is contained in:
Georg Richter
2014-12-21 17:43:38 +01:00
parent cace488e9f
commit 04c05f4d44
2 changed files with 22 additions and 1 deletions

View File

@@ -2030,6 +2030,7 @@ static my_bool mysql_reconnect(MYSQL *mysql)
my_set_error(mysql, tmp_mysql.net.last_errno, my_set_error(mysql, tmp_mysql.net.last_errno,
tmp_mysql.net.sqlstate, tmp_mysql.net.sqlstate,
tmp_mysql.net.last_error); tmp_mysql.net.last_error);
mysql_close(&tmp_mysql);
DBUG_RETURN(1); DBUG_RETURN(1);
} }

View File

@@ -982,7 +982,27 @@ static int test_conc_114(MYSQL *mysql)
return OK; return OK;
} }
/* run with valgrind */
static int test_conc117(MYSQL *mysql)
{
MYSQL *my= mysql_init(NULL);
FAIL_IF(!mysql_real_connect(my, hostname, username, password, schema,
port, socketname, 0), mysql_error(my));
mysql_kill(my, mysql_thread_id(my));
sleep(5);
strcpy(my->host, "A");
my->reconnect= 1;
mysql_query(my, "SET @a:=1");
mysql_close(my);
return OK;
}
struct my_tests_st my_tests[] = { struct my_tests_st my_tests[] = {
{"test_conc117", test_conc117, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_conc_114", test_conc_114, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, {"test_conc_114", test_conc_114, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_connect_attrs", test_connect_attrs, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, {"test_connect_attrs", test_connect_attrs, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
{"test_conc49", test_conc49, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, {"test_conc49", test_conc49, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},