Skip to content

Commit 04c05f4

Browse files
committed
Fix for CONC-117:
if reconnecting fails (e.g. server has gone) we don't freee memory associated with tmp_mysql.
1 parent cace488 commit 04c05f4

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

libmariadb/libmariadb.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,6 +2030,7 @@ static my_bool mysql_reconnect(MYSQL *mysql)
20302030
my_set_error(mysql, tmp_mysql.net.last_errno,
20312031
tmp_mysql.net.sqlstate,
20322032
tmp_mysql.net.last_error);
2033+
mysql_close(&tmp_mysql);
20332034
DBUG_RETURN(1);
20342035
}
20352036

unittest/libmariadb/misc.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,27 @@ static int test_conc_114(MYSQL *mysql)
982982
return OK;
983983
}
984984

985+
/* run with valgrind */
986+
static int test_conc117(MYSQL *mysql)
987+
{
988+
MYSQL *my= mysql_init(NULL);
989+
FAIL_IF(!mysql_real_connect(my, hostname, username, password, schema,
990+
port, socketname, 0), mysql_error(my));
991+
992+
mysql_kill(my, mysql_thread_id(my));
993+
sleep(5);
994+
995+
strcpy(my->host, "A");
996+
my->reconnect= 1;
997+
998+
mysql_query(my, "SET @a:=1");
999+
mysql_close(my);
1000+
1001+
return OK;
1002+
}
1003+
9851004
struct my_tests_st my_tests[] = {
1005+
{"test_conc117", test_conc117, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
9861006
{"test_conc_114", test_conc_114, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
9871007
{"test_connect_attrs", test_connect_attrs, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
9881008
{"test_conc49", test_conc49, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
@@ -1002,7 +1022,7 @@ struct my_tests_st my_tests[] = {
10021022
{"test_ldi_path", test_ldi_path, TEST_CONNECTION_NEW, 0, NULL, NULL},
10031023
#ifdef _WIN32
10041024
{"test_conc44", test_conc44, TEST_CONNECTION_NEW, 0, NULL, NULL},
1005-
#endif
1025+
#endif
10061026
{NULL, NULL, 0, 0, NULL, 0}
10071027
};
10081028

0 commit comments

Comments
 (0)