You've already forked mariadb-connector-c
mirror of
https://github.com/mariadb-corporation/mariadb-connector-c.git
synced 2025-08-07 02:42:49 +03:00
CONC-760: valid named pipe connection is closed
Fixed different behavior of pvio_is_alive (which was first used with fix of CONC-589). Both for sockets and named pipe the function now returns true if the connection is alive, otherwise false.
This commit is contained in:
@@ -2002,7 +2002,6 @@ static int test_conc748(MYSQL *my __attribute__((unused)))
|
||||
static int test_conc589(MYSQL *my)
|
||||
{
|
||||
MYSQL *mysql= mysql_init(NULL);
|
||||
MYSQL_RES *result;
|
||||
int rc;
|
||||
my_bool reconnect= 1, verify= 0;
|
||||
unsigned long last_thread_id= 0;
|
||||
@@ -2022,6 +2021,72 @@ static int test_conc589(MYSQL *my)
|
||||
rc= mysql_query(mysql, "SET SESSION wait_timeout=5");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
last_thread_id= mysql_thread_id(mysql);
|
||||
rc= mysql_query(mysql, "SET @a:=1");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
sleep(10);
|
||||
|
||||
rc= mysql_query(mysql, "SET @a:=2");
|
||||
check_mysql_rc(rc, mysql);
|
||||
FAIL_IF(mysql_thread_id(mysql) == last_thread_id, "Expected new connection id");
|
||||
last_thread_id= mysql_thread_id(mysql);
|
||||
|
||||
mysql_kill(my, last_thread_id);
|
||||
|
||||
sleep(10);
|
||||
|
||||
rc= mysql_query(mysql, "SET @a:=3");
|
||||
check_mysql_rc(rc, mysql);
|
||||
FAIL_IF(mysql_thread_id(mysql) == last_thread_id, "Expected new connection id");
|
||||
mysql_close(mysql);
|
||||
return OK;
|
||||
}
|
||||
|
||||
#ifdef WIN32
|
||||
static int test_conc760(MYSQL *my)
|
||||
{
|
||||
MYSQL *mysql= mysql_init(NULL);
|
||||
MYSQL_RES *result;
|
||||
MYSQL_ROW row;
|
||||
int rc;
|
||||
my_bool reconnect= 1, verify= 0;
|
||||
unsigned long last_thread_id= 0;
|
||||
unsigned int protocol= MYSQL_PROTOCOL_PIPE;
|
||||
my_bool have_named_pipe= 0;
|
||||
|
||||
SKIP_MAXSCALE;
|
||||
|
||||
rc= mysql_query(my, "select @@named_pipe");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
if ((result= mysql_store_result(my)))
|
||||
{
|
||||
if((row= mysql_fetch_row(result)))
|
||||
have_named_pipe= atoi(row[0]);
|
||||
mysql_free_result(result);
|
||||
}
|
||||
|
||||
if (!have_named_pipe)
|
||||
{
|
||||
diag("Server doesn't support named pipes");
|
||||
return SKIP;
|
||||
}
|
||||
|
||||
mysql_options(mysql, MYSQL_OPT_RECONNECT, &reconnect);
|
||||
mysql_options(mysql, MYSQL_OPT_SSL_VERIFY_SERVER_CERT, &verify);
|
||||
mysql_options(mysql, MYSQL_OPT_PROTOCOL, &protocol);
|
||||
|
||||
if (!my_test_connect(mysql, hostname, username,
|
||||
password, schema, port, socketname, CLIENT_REMEMBER_OPTIONS))
|
||||
{
|
||||
diag("error: %s", mysql_error(mysql));
|
||||
return FAIL;
|
||||
}
|
||||
|
||||
rc= mysql_query(mysql, "SET SESSION wait_timeout=5");
|
||||
check_mysql_rc(rc, mysql);
|
||||
|
||||
last_thread_id= mysql_thread_id(mysql);
|
||||
if ((rc= mysql_query(mysql, "SELECT 1")) || (result= mysql_store_result(mysql)) == NULL)
|
||||
check_mysql_rc(rc, mysql);
|
||||
@@ -2029,9 +2094,10 @@ static int test_conc589(MYSQL *my)
|
||||
mysql_free_result(result);
|
||||
sleep(10);
|
||||
|
||||
if ((rc= mysql_query(mysql, "SELECT 2")) || (result= mysql_store_result(mysql)) == NULL)
|
||||
check_mysql_rc(rc, mysql);
|
||||
mysql_free_result(result);
|
||||
rc= mysql_query(mysql, "SELECT 2");
|
||||
check_mysql_rc(rc, mysql);
|
||||
if (result= mysql_store_result(mysql))
|
||||
mysql_free_result(result);
|
||||
FAIL_IF(mysql_thread_id(mysql) == last_thread_id, "Expected new connection id");
|
||||
last_thread_id= mysql_thread_id(mysql);
|
||||
|
||||
@@ -2046,8 +2112,12 @@ static int test_conc589(MYSQL *my)
|
||||
mysql_close(mysql);
|
||||
return OK;
|
||||
}
|
||||
#endif
|
||||
|
||||
struct my_tests_st my_tests[] = {
|
||||
#ifdef WIN32
|
||||
{"test_conc760", test_conc760, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
#endif
|
||||
{"test_conc589", test_conc589, TEST_CONNECTION_DEFAULT, 0, NULL, NULL},
|
||||
#ifdef HAVE_test_conc748
|
||||
{"test_conc748", test_conc748, TEST_CONNECTION_NONE, 0, NULL, NULL},
|
||||
|
Reference in New Issue
Block a user