You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-08 14:02:17 +03:00
Test fixes:
- fixed tls callback function declarations - fixed memory leaks
This commit is contained in:
@@ -27,7 +27,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||||||
|
|
||||||
#include "my_test.h"
|
#include "my_test.h"
|
||||||
|
|
||||||
#define FORCE_RECONNECT(mysql) (mysql)->net.pvio= 0
|
|
||||||
|
static int kill_conn(MYSQL *mysql, unsigned long thread_id)
|
||||||
|
{
|
||||||
|
char query[128];
|
||||||
|
sprintf(query, "KILL %ld", thread_id);
|
||||||
|
return mysql_query(mysql, query);
|
||||||
|
}
|
||||||
|
|
||||||
static int test_conc66(MYSQL *my)
|
static int test_conc66(MYSQL *my)
|
||||||
{
|
{
|
||||||
@@ -2444,7 +2450,7 @@ static int test_conc748(MYSQL *my __attribute__((unused)))
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int test_conc589(MYSQL *my __attribute__((unused)))
|
static int test_conc589(MYSQL *my)
|
||||||
{
|
{
|
||||||
MYSQL *mysql= mysql_init(NULL);
|
MYSQL *mysql= mysql_init(NULL);
|
||||||
MYSQL_RES *result;
|
MYSQL_RES *result;
|
||||||
@@ -2466,19 +2472,22 @@ static int test_conc589(MYSQL *my __attribute__((unused)))
|
|||||||
if ((rc= mysql_query(mysql, "SELECT 1")) || (result= mysql_store_result(mysql)) == NULL)
|
if ((rc= mysql_query(mysql, "SELECT 1")) || (result= mysql_store_result(mysql)) == NULL)
|
||||||
check_mysql_rc(rc, mysql);
|
check_mysql_rc(rc, mysql);
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
FORCE_RECONNECT(mysql);
|
rc= kill_conn(my, last_thread_id);
|
||||||
|
check_mysql_rc(rc, my);
|
||||||
if ((rc= mysql_query(mysql, "SELECT 1")) || (result= mysql_store_result(mysql)) == NULL)
|
if ((rc= mysql_query(mysql, "SELECT 1")) || (result= mysql_store_result(mysql)) == NULL)
|
||||||
check_mysql_rc(rc, mysql);
|
check_mysql_rc(rc, mysql);
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
FAIL_IF(mysql_thread_id(mysql) == last_thread_id, "Expected new connection id");
|
FAIL_IF(mysql_thread_id(mysql) == last_thread_id, "Expected new connection id");
|
||||||
last_thread_id= mysql_thread_id(mysql);
|
last_thread_id= mysql_thread_id(mysql);
|
||||||
FORCE_RECONNECT(mysql);
|
rc= kill_conn(my, last_thread_id);
|
||||||
|
check_mysql_rc(rc, my);
|
||||||
if ((rc= mysql_query(mysql, "SELECT 1")) || (result= mysql_store_result(mysql)) == NULL)
|
if ((rc= mysql_query(mysql, "SELECT 1")) || (result= mysql_store_result(mysql)) == NULL)
|
||||||
check_mysql_rc(rc, mysql);
|
check_mysql_rc(rc, mysql);
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
FAIL_IF(mysql_thread_id(mysql) == last_thread_id, "Expected new connection id");
|
FAIL_IF(mysql_thread_id(mysql) == last_thread_id, "Expected new connection id");
|
||||||
last_thread_id= mysql_thread_id(mysql);
|
last_thread_id= mysql_thread_id(mysql);
|
||||||
FORCE_RECONNECT(mysql);
|
rc= kill_conn(my, last_thread_id);
|
||||||
|
check_mysql_rc(rc, my);
|
||||||
if ((rc= mysql_query(mysql, "SELECT 1")) || (result= mysql_store_result(mysql)) == NULL)
|
if ((rc= mysql_query(mysql, "SELECT 1")) || (result= mysql_store_result(mysql)) == NULL)
|
||||||
check_mysql_rc(rc, mysql);
|
check_mysql_rc(rc, mysql);
|
||||||
mysql_free_result(result);
|
mysql_free_result(result);
|
||||||
@@ -2489,7 +2498,7 @@ static int test_conc589(MYSQL *my __attribute__((unused)))
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct my_tests_st my_tests[] = {
|
struct my_tests_st my_tests[] = {
|
||||||
{"test_conc589", test_conc589, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
{"test_conc589", test_conc589, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
{"test_tls_timeout", test_tls_timeout, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
{"test_tls_timeout", test_tls_timeout, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||||
{"test_parsec", test_parsec, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
{"test_parsec", test_parsec, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||||
#if defined(HAVE_GNUTLS) || defined(HAVE_OPENSSL)
|
#if defined(HAVE_GNUTLS) || defined(HAVE_OPENSSL)
|
||||||
|
@@ -109,7 +109,7 @@ static my_bool ignore_self_signed_cert_error(MYSQL *mysql)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static my_bool tls_abort_after_handshake(MARIADB_TLS *ctls, unsigned int flags)
|
static int tls_abort_after_handshake(MARIADB_TLS *ctls, unsigned int flags)
|
||||||
{
|
{
|
||||||
MYSQL *mysql= ctls->pvio->mysql;
|
MYSQL *mysql= ctls->pvio->mysql;
|
||||||
|
|
||||||
@@ -210,6 +210,7 @@ static int set_tls_dummy_options(const char *options)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ma_pvio_close(pvio);
|
ma_pvio_close(pvio);
|
||||||
|
mysql_close(mysql);
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -649,7 +650,7 @@ static int stop_tls_server(MYSQL *my __attribute__((unused)))
|
|||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static my_bool tls_wildcard_callback(MARIADB_TLS *ctls, unsigned int flags)
|
static int tls_wildcard_callback(MARIADB_TLS *ctls, unsigned int flags)
|
||||||
{
|
{
|
||||||
MYSQL *mysql= ctls->pvio->mysql;
|
MYSQL *mysql= ctls->pvio->mysql;
|
||||||
|
|
||||||
@@ -838,6 +839,10 @@ int main(int argc, char **argv)
|
|||||||
{
|
{
|
||||||
char *dummy_port;
|
char *dummy_port;
|
||||||
|
|
||||||
|
#ifdef HAVE_GNUTLS
|
||||||
|
diag("GnuTLS_config: %s", gnutls_get_system_config_file());
|
||||||
|
#endif
|
||||||
|
|
||||||
if (argc > 1)
|
if (argc > 1)
|
||||||
get_options(argc, argv);
|
get_options(argc, argv);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user