From abf0080bfa0a4255713034eb60245f2d890652da Mon Sep 17 00:00:00 2001 From: Georg Richter Date: Tue, 8 Sep 2015 07:33:30 +0200 Subject: [PATCH] Fix for CONC-129 (asynchronous api): Check if connection is still alive in mysql_close_start --- libmariadb/mysql_async.c | 2 +- unittest/libmariadb/async.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libmariadb/mysql_async.c b/libmariadb/mysql_async.c index e1424509..7d5ae3b7 100644 --- a/libmariadb/mysql_async.c +++ b/libmariadb/mysql_async.c @@ -805,7 +805,7 @@ mysql_close_start(MYSQL *sock) int res; /* It is legitimate to have NULL sock argument, which will do nothing. */ - if (sock) + if (sock && sock->net.vio) { res= mysql_close_slow_part_start(sock); /* If we need to block, return now and do the rest in mysql_close_cont(). */ diff --git a/unittest/libmariadb/async.c b/unittest/libmariadb/async.c index 4a947ab9..e54fb74d 100644 --- a/unittest/libmariadb/async.c +++ b/unittest/libmariadb/async.c @@ -200,10 +200,17 @@ static int test_conc131(MYSQL *my) return OK; } +static int test_conc129(MYSQL *my) +{ + MYSQL *mysql= mysql_init(NULL); + FAIL_IF(mysql_close_start(mysql), "No error expected"); +} + struct my_tests_st my_tests[] = { {"async1", async1, TEST_CONNECTION_DEFAULT, 0, NULL, NULL}, {"test_conc131", test_conc131, TEST_CONNECTION_NONE, 0, NULL, NULL}, + {"test_conc129", test_conc129, TEST_CONNECTION_NONE, 0, NULL, NULL}, {NULL, NULL, 0, 0, NULL, NULL} };