1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-08 14:02:17 +03:00

Removed option WITH_NONBLOCK

This commit is contained in:
Georg Richter
2016-03-10 09:51:53 +01:00
parent 454a95768f
commit 3cfc5f8654
5 changed files with 5 additions and 68 deletions

View File

@@ -43,7 +43,6 @@ ENDIF()
OPTION(WITH_UNITTEST "build test suite" ON) OPTION(WITH_UNITTEST "build test suite" ON)
OPTION(WITH_DYNCOL "Enables support of dynamic coluumns" ON) OPTION(WITH_DYNCOL "Enables support of dynamic coluumns" ON)
OPTION(WITH_NONBLOCK "Enables support for non blocking operations" ON)
OPTION(WITH_EXTERNAL_ZLIB "Enables use of external zlib" OFF) OPTION(WITH_EXTERNAL_ZLIB "Enables use of external zlib" OFF)
############### ###############
IF(WITH_SIGNCODE) IF(WITH_SIGNCODE)

View File

@@ -141,10 +141,8 @@ ENDIF()
# some gcc versions fail to compile asm parts of my_context.c, # some gcc versions fail to compile asm parts of my_context.c,
# if build type is "Release" (see CONC-133), so we need to add -g flag # if build type is "Release" (see CONC-133), so we need to add -g flag
IF(WITH_NONBLOCK) IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_BUILD_TYPE MATCHES "Release")
IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_BUILD_TYPE MATCHES "Release") SET_SOURCE_FILES_PROPERTIES(my_context.c PROPERTIES COMPILE_FLAGS -g)
SET_SOURCE_FILES_PROPERTIES(my_context.c PROPERTIES COMPILE_FLAGS -g)
ENDIF()
ENDIF() ENDIF()
SET(MARIADB_DYNCOL_SYMBOLS SET(MARIADB_DYNCOL_SYMBOLS
@@ -310,12 +308,8 @@ IF(WITH_DYNCOL)
SET(LIBMARIADB_SOURCES ${LIBMARIADB_SOURCES} mariadb_dyncol.c) SET(LIBMARIADB_SOURCES ${LIBMARIADB_SOURCES} mariadb_dyncol.c)
ENDIF() ENDIF()
IF(WITH_NONBLOCK) SET(LIBMARIADB_SOURCES ${LIBMARIADB_SOURCES} mariadb_async.c ma_context.c)
MESSAGE(STATUS "Non blocking API support=ON") SET(MARIADB_LIB_SYMBOLS ${MARIADB_LIB_SYMBOLS} ${MARIADB_NONBLOCK_SYMBOLS})
SET(LIBMARIADB_SOURCES ${LIBMARIADB_SOURCES} mariadb_async.c ma_context.c)
SET(MARIADB_LIB_SYMBOLS ${MARIADB_LIB_SYMBOLS} ${MARIADB_NONBLOCK_SYMBOLS})
ADD_DEFINITIONS(-DHAVE_NONBLOCK)
ENDIF()
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/export.cmake) INCLUDE(${CMAKE_SOURCE_DIR}/cmake/export.cmake)
CREATE_EXPORT_FILE(mariadbclient CREATE_EXPORT_FILE(mariadbclient

View File

@@ -27,9 +27,7 @@
#include <ma_string.h> #include <ma_string.h>
#include <mariadb_ctype.h> #include <mariadb_ctype.h>
#include <ma_common.h> #include <ma_common.h>
#ifdef HAVE_NONBLOCK
#include "ma_context.h" #include "ma_context.h"
#endif
#include "mysql.h" #include "mysql.h"
#include "mariadb_version.h" #include "mariadb_version.h"
#include "ma_server_error.h" #include "ma_server_error.h"
@@ -105,12 +103,10 @@ extern my_bool _mariadb_read_options(MYSQL *mysql, const char *config_file,
char *group); char *group);
extern unsigned char *mysql_net_store_length(unsigned char *packet, size_t length); extern unsigned char *mysql_net_store_length(unsigned char *packet, size_t length);
#ifdef HAVE_NONBLOCK
extern void extern void
my_context_install_suspend_resume_hook(struct mysql_async_context *b, my_context_install_suspend_resume_hook(struct mysql_async_context *b,
void (*hook)(my_bool, void *), void (*hook)(my_bool, void *),
void *user_data); void *user_data);
#endif
uint mysql_port=0; uint mysql_port=0;
my_string mysql_unix_port=0; my_string mysql_unix_port=0;
@@ -1535,7 +1531,6 @@ struct my_hook_data {
Callback hook to make the new VIO accessible via the old MYSQL to calling Callback hook to make the new VIO accessible via the old MYSQL to calling
application when suspending a non-blocking call during automatic reconnect. application when suspending a non-blocking call during automatic reconnect.
*/ */
#ifdef HAVE_NONBLOCK
static void static void
my_suspend_hook(my_bool suspend, void *data) my_suspend_hook(my_bool suspend, void *data)
{ {
@@ -1548,15 +1543,12 @@ my_suspend_hook(my_bool suspend, void *data)
else else
hook_data->orig_mysql->net.pvio= hook_data->orig_pvio; hook_data->orig_mysql->net.pvio= hook_data->orig_pvio;
} }
#endif
my_bool STDCALL mariadb_reconnect(MYSQL *mysql) my_bool STDCALL mariadb_reconnect(MYSQL *mysql)
{ {
MYSQL tmp_mysql; MYSQL tmp_mysql;
#ifdef HAVE_NONBLOCK
struct my_hook_data hook_data; struct my_hook_data hook_data;
struct mysql_async_context *ctxt= NULL; struct mysql_async_context *ctxt= NULL;
#endif
LIST *li_stmt= mysql->stmts; LIST *li_stmt= mysql->stmts;
mysql_init(&tmp_mysql); mysql_init(&tmp_mysql);
@@ -1588,7 +1580,6 @@ my_bool STDCALL mariadb_reconnect(MYSQL *mysql)
/* don't reread options from configuration files */ /* don't reread options from configuration files */
tmp_mysql.options.my_cnf_group= tmp_mysql.options.my_cnf_file= NULL; tmp_mysql.options.my_cnf_group= tmp_mysql.options.my_cnf_file= NULL;
#ifdef HAVE_NONBLOCK
if (IS_MYSQL_ASYNC_ACTIVE(mysql)) if (IS_MYSQL_ASYNC_ACTIVE(mysql))
{ {
hook_data.orig_mysql= mysql; hook_data.orig_mysql= mysql;
@@ -1596,17 +1587,14 @@ my_bool STDCALL mariadb_reconnect(MYSQL *mysql)
hook_data.orig_pvio= mysql->net.pvio; hook_data.orig_pvio= mysql->net.pvio;
my_context_install_suspend_resume_hook(ctxt, my_suspend_hook, &hook_data); my_context_install_suspend_resume_hook(ctxt, my_suspend_hook, &hook_data);
} }
#endif
if (!mysql_real_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd, if (!mysql_real_connect(&tmp_mysql,mysql->host,mysql->user,mysql->passwd,
mysql->db, mysql->port, mysql->unix_socket, mysql->db, mysql->port, mysql->unix_socket,
mysql->client_flag | CLIENT_REMEMBER_OPTIONS) || mysql->client_flag | CLIENT_REMEMBER_OPTIONS) ||
mysql_set_character_set(&tmp_mysql, mysql->charset->csname)) mysql_set_character_set(&tmp_mysql, mysql->charset->csname))
{ {
#ifdef HAVE_NONBLOCK
if (ctxt) if (ctxt)
my_context_install_suspend_resume_hook(ctxt, NULL, NULL); my_context_install_suspend_resume_hook(ctxt, NULL, NULL);
#endif
/* don't free options (CONC-118) */ /* don't free options (CONC-118) */
memset(&tmp_mysql.options, 0, sizeof(struct st_mysql_options)); memset(&tmp_mysql.options, 0, sizeof(struct st_mysql_options));
my_set_error(mysql, tmp_mysql.net.last_errno, my_set_error(mysql, tmp_mysql.net.last_errno,
@@ -1667,27 +1655,19 @@ void ma_invalidate_stmts(MYSQL *mysql, const char *function_name)
unsigned int STDCALL unsigned int STDCALL
mysql_get_timeout_value(const MYSQL *mysql) mysql_get_timeout_value(const MYSQL *mysql)
{ {
#ifdef HAVE_NONBLOCK
unsigned int timeout= mysql->options.extension->async_context->timeout_value; unsigned int timeout= mysql->options.extension->async_context->timeout_value;
/* Avoid overflow. */ /* Avoid overflow. */
if (timeout > UINT_MAX - 999) if (timeout > UINT_MAX - 999)
return (timeout - 1)/1000 + 1; return (timeout - 1)/1000 + 1;
else else
return (timeout+999)/1000; return (timeout+999)/1000;
#else
return 0;
#endif
} }
unsigned int STDCALL unsigned int STDCALL
mysql_get_timeout_value_ms(const MYSQL *mysql) mysql_get_timeout_value_ms(const MYSQL *mysql)
{ {
#ifdef HAVE_NONBLOCK
return mysql->options.extension->async_context->timeout_value; return mysql->options.extension->async_context->timeout_value;
#else
return 0;
#endif
} }
/************************************************************************** /**************************************************************************
@@ -1805,14 +1785,12 @@ static void mysql_close_options(MYSQL *mysql)
if (mysql->options.extension) if (mysql->options.extension)
{ {
#ifdef HAVE_NONBLOCK
struct mysql_async_context *ctxt; struct mysql_async_context *ctxt;
if ((ctxt = mysql->options.extension->async_context) != 0) if ((ctxt = mysql->options.extension->async_context) != 0)
{ {
my_context_destroy(&ctxt->async_context); my_context_destroy(&ctxt->async_context);
free(ctxt); free(ctxt);
} }
#endif
free(mysql->options.extension->plugin_dir); free(mysql->options.extension->plugin_dir);
free(mysql->options.extension->default_auth); free(mysql->options.extension->default_auth);
free(mysql->options.extension->db_driver); free(mysql->options.extension->db_driver);
@@ -2479,10 +2457,8 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
{ {
va_list ap; va_list ap;
void *arg1; void *arg1;
#ifdef HAVE_NONBLOCK
size_t stacksize; size_t stacksize;
struct mysql_async_context *ctxt; struct mysql_async_context *ctxt;
#endif
va_start(ap, option); va_start(ap, option);
@@ -2548,7 +2524,6 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
OPT_SET_EXTENDED_VALUE_STR(&mysql->options, default_auth, (char *)arg1); OPT_SET_EXTENDED_VALUE_STR(&mysql->options, default_auth, (char *)arg1);
break; break;
case MYSQL_OPT_NONBLOCK: case MYSQL_OPT_NONBLOCK:
#ifdef HAVE_NONBLOCK
if (mysql->options.extension && if (mysql->options.extension &&
(ctxt = mysql->options.extension->async_context) != 0) (ctxt = mysql->options.extension->async_context) != 0)
{ {
@@ -2587,7 +2562,6 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...)
mysql->options.extension->async_context= ctxt; mysql->options.extension->async_context= ctxt;
if (mysql->net.pvio) if (mysql->net.pvio)
mysql->net.pvio->async_context= ctxt; mysql->net.pvio->async_context= ctxt;
#endif
break; break;
case MYSQL_OPT_MAX_ALLOWED_PACKET: case MYSQL_OPT_MAX_ALLOWED_PACKET:
if (mysql) if (mysql)
@@ -3436,13 +3410,11 @@ static my_socket mariadb_get_socket(MYSQL *mysql)
pvio handle from async_context until the connection was pvio handle from async_context until the connection was
successfully established. successfully established.
*/ */
#ifdef HAVE_NONBLOCK
else if (mysql->options.extension && mysql->options.extension->async_context && else if (mysql->options.extension && mysql->options.extension->async_context &&
mysql->options.extension->async_context->pvio) mysql->options.extension->async_context->pvio)
{ {
ma_pvio_get_handle(mysql->options.extension->async_context->pvio, &sock); ma_pvio_get_handle(mysql->options.extension->async_context->pvio, &sock);
} }
#endif
return sock; return sock;
} }
@@ -3576,15 +3548,10 @@ my_bool STDCALL mariadb_get_infov(MYSQL *mysql, enum mariadb_value value, void *
goto error; goto error;
break; break;
case MARIADB_CONNECTION_ASYNC_TIMEOUT_MS: case MARIADB_CONNECTION_ASYNC_TIMEOUT_MS:
#ifdef HAVE_NONBLOCK
if (mysql && mysql->options.extension && mysql->options.extension->async_context) if (mysql && mysql->options.extension && mysql->options.extension->async_context)
*((unsigned int *)arg)= mysql->options.extension->async_context->timeout_value; *((unsigned int *)arg)= mysql->options.extension->async_context->timeout_value;
else
#endif
goto error;
break; break;
case MARIADB_CONNECTION_ASYNC_TIMEOUT: case MARIADB_CONNECTION_ASYNC_TIMEOUT:
#ifdef HAVE_NONBLOCK
if (mysql && mysql->options.extension && mysql->options.extension->async_context) if (mysql && mysql->options.extension && mysql->options.extension->async_context)
{ {
unsigned int timeout= mysql->options.extension->async_context->timeout_value; unsigned int timeout= mysql->options.extension->async_context->timeout_value;
@@ -3593,9 +3560,6 @@ my_bool STDCALL mariadb_get_infov(MYSQL *mysql, enum mariadb_value value, void *
else else
*((unsigned int *)arg)= (timeout+999)/1000; *((unsigned int *)arg)= (timeout+999)/1000;
} }
else
#endif
goto error;
break; break;
case MARIADB_CHARSET_NAME: case MARIADB_CHARSET_NAME:
{ {

View File

@@ -29,10 +29,8 @@
#include <ma_errmsg.h> #include <ma_errmsg.h>
#include <mysql.h> #include <mysql.h>
#include <mysql/client_plugin.h> #include <mysql/client_plugin.h>
#ifdef HAVE_NONBLOCK
#include <ma_context.h> #include <ma_context.h>
#include <mariadb_async.h> #include <mariadb_async.h>
#endif
#include <ma_common.h> #include <ma_common.h>
#include <string.h> #include <string.h>
#ifndef _WIN32 #ifndef _WIN32
@@ -65,10 +63,8 @@
my_bool pvio_socket_set_timeout(MARIADB_PVIO *pvio, enum enum_pvio_timeout type, int timeout); my_bool pvio_socket_set_timeout(MARIADB_PVIO *pvio, enum enum_pvio_timeout type, int timeout);
int pvio_socket_get_timeout(MARIADB_PVIO *pvio, enum enum_pvio_timeout type); int pvio_socket_get_timeout(MARIADB_PVIO *pvio, enum enum_pvio_timeout type);
size_t pvio_socket_read(MARIADB_PVIO *pvio, uchar *buffer, size_t length); size_t pvio_socket_read(MARIADB_PVIO *pvio, uchar *buffer, size_t length);
#ifdef HAVE_NONBLOCK
size_t pvio_socket_async_read(MARIADB_PVIO *pvio, uchar *buffer, size_t length); size_t pvio_socket_async_read(MARIADB_PVIO *pvio, uchar *buffer, size_t length);
size_t pvio_socket_async_write(MARIADB_PVIO *pvio, const uchar *buffer, size_t length); size_t pvio_socket_async_write(MARIADB_PVIO *pvio, const uchar *buffer, size_t length);
#endif
size_t pvio_socket_write(MARIADB_PVIO *pvio, const uchar *buffer, size_t length); size_t pvio_socket_write(MARIADB_PVIO *pvio, const uchar *buffer, size_t length);
int pvio_socket_wait_io_or_timeout(MARIADB_PVIO *pvio, my_bool is_read, int timeout); int pvio_socket_wait_io_or_timeout(MARIADB_PVIO *pvio, my_bool is_read, int timeout);
my_bool pvio_socket_blocking(MARIADB_PVIO *pvio, my_bool value, my_bool *old_value); my_bool pvio_socket_blocking(MARIADB_PVIO *pvio, my_bool value, my_bool *old_value);
@@ -91,17 +87,9 @@ struct st_ma_pvio_methods pvio_socket_methods= {
pvio_socket_set_timeout, pvio_socket_set_timeout,
pvio_socket_get_timeout, pvio_socket_get_timeout,
pvio_socket_read, pvio_socket_read,
#ifdef HAVE_NONBLOCK
pvio_socket_async_read, pvio_socket_async_read,
#else
NULL,
#endif
pvio_socket_write, pvio_socket_write,
#ifdef HAVE_NONBLOCK
pvio_socket_async_write, pvio_socket_async_write,
#else
NULL,
#endif
pvio_socket_wait_io_or_timeout, pvio_socket_wait_io_or_timeout,
pvio_socket_blocking, pvio_socket_blocking,
pvio_socket_connect, pvio_socket_connect,
@@ -319,7 +307,6 @@ size_t pvio_socket_read(MARIADB_PVIO *pvio, uchar *buffer, size_t length)
} }
/* }}} */ /* }}} */
#ifdef HAVE_NONBLOCK
/* {{{ pvio_socket_async_read */ /* {{{ pvio_socket_async_read */
/* /*
read from socket read from socket
@@ -430,7 +417,6 @@ size_t pvio_socket_async_write(MARIADB_PVIO *pvio, const uchar *buffer, size_t l
return r; return r;
} }
/* }}} */ /* }}} */
#endif
/* {{{ pvio_socket_write */ /* {{{ pvio_socket_write */
/* /*
@@ -738,7 +724,6 @@ static int
pvio_socket_connect_sync_or_async(MARIADB_PVIO *pvio, pvio_socket_connect_sync_or_async(MARIADB_PVIO *pvio,
const struct sockaddr *name, uint namelen) const struct sockaddr *name, uint namelen)
{ {
#ifdef HAVE_NONBLOCK
MYSQL *mysql= pvio->mysql; MYSQL *mysql= pvio->mysql;
if (mysql->options.extension && mysql->options.extension->async_context && if (mysql->options.extension && mysql->options.extension->async_context &&
mysql->options.extension->async_context->active) mysql->options.extension->async_context->active)
@@ -749,7 +734,6 @@ pvio_socket_connect_sync_or_async(MARIADB_PVIO *pvio,
pvio_socket_blocking(pvio, 0, 0); pvio_socket_blocking(pvio, 0, 0);
return my_connect_async(pvio, name, namelen, pvio->timeout[PVIO_CONNECT_TIMEOUT]); return my_connect_async(pvio, name, namelen, pvio->timeout[PVIO_CONNECT_TIMEOUT]);
} }
#endif
return pvio_socket_internal_connect(pvio, name, namelen); return pvio_socket_internal_connect(pvio, name, namelen);
} }
@@ -866,12 +850,10 @@ my_bool pvio_socket_connect(MARIADB_PVIO *pvio, MA_PVIO_CINFO *cinfo)
rc= pvio_socket_connect_sync_or_async(pvio, save_res->ai_addr, (uint)save_res->ai_addrlen); rc= pvio_socket_connect_sync_or_async(pvio, save_res->ai_addr, (uint)save_res->ai_addrlen);
if (!rc) if (!rc)
{ {
#ifdef HAVE_NONBLOCK
MYSQL *mysql= pvio->mysql; MYSQL *mysql= pvio->mysql;
if (mysql->options.extension && mysql->options.extension->async_context && if (mysql->options.extension && mysql->options.extension->async_context &&
mysql->options.extension->async_context->active) mysql->options.extension->async_context->active)
break; break;
#endif
if (pvio_socket_blocking(pvio, 0, 0) == SOCKET_ERROR) if (pvio_socket_blocking(pvio, 0, 0) == SOCKET_ERROR)
{ {
closesocket(csock->socket); closesocket(csock->socket);

View File

@@ -27,9 +27,7 @@ IF(WITH_DYNCOL)
SET(API_TESTS ${API_TESTS} "dyncol") SET(API_TESTS ${API_TESTS} "dyncol")
ENDIF() ENDIF()
IF(WITH_NONBLCK) SET(API_TESTS ${API_TESTS} "async")
SET(API_TESTS ${API_TESTS} "async")
ENDIF()
#exclude following tests from ctests, since we need to run them maually with different credentials #exclude following tests from ctests, since we need to run them maually with different credentials
SET(MANUAL_TESTS "t_aurora") SET(MANUAL_TESTS "t_aurora")