diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d24c059..808e2bc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,6 @@ ENDIF() OPTION(WITH_UNITTEST "build test suite" 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) ############### IF(WITH_SIGNCODE) diff --git a/libmariadb/CMakeLists.txt b/libmariadb/CMakeLists.txt index c79721ee..67fade1b 100644 --- a/libmariadb/CMakeLists.txt +++ b/libmariadb/CMakeLists.txt @@ -141,10 +141,8 @@ ENDIF() # 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(WITH_NONBLOCK) - IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_BUILD_TYPE MATCHES "Release") - SET_SOURCE_FILES_PROPERTIES(my_context.c PROPERTIES COMPILE_FLAGS -g) - ENDIF() +IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_BUILD_TYPE MATCHES "Release") + SET_SOURCE_FILES_PROPERTIES(my_context.c PROPERTIES COMPILE_FLAGS -g) ENDIF() SET(MARIADB_DYNCOL_SYMBOLS @@ -310,12 +308,8 @@ IF(WITH_DYNCOL) SET(LIBMARIADB_SOURCES ${LIBMARIADB_SOURCES} mariadb_dyncol.c) ENDIF() -IF(WITH_NONBLOCK) - MESSAGE(STATUS "Non blocking API support=ON") - 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() +SET(LIBMARIADB_SOURCES ${LIBMARIADB_SOURCES} mariadb_async.c ma_context.c) +SET(MARIADB_LIB_SYMBOLS ${MARIADB_LIB_SYMBOLS} ${MARIADB_NONBLOCK_SYMBOLS}) INCLUDE(${CMAKE_SOURCE_DIR}/cmake/export.cmake) CREATE_EXPORT_FILE(mariadbclient diff --git a/libmariadb/mariadb_lib.c b/libmariadb/mariadb_lib.c index b312181d..909432f4 100644 --- a/libmariadb/mariadb_lib.c +++ b/libmariadb/mariadb_lib.c @@ -27,9 +27,7 @@ #include #include #include -#ifdef HAVE_NONBLOCK #include "ma_context.h" -#endif #include "mysql.h" #include "mariadb_version.h" #include "ma_server_error.h" @@ -105,12 +103,10 @@ extern my_bool _mariadb_read_options(MYSQL *mysql, const char *config_file, char *group); extern unsigned char *mysql_net_store_length(unsigned char *packet, size_t length); -#ifdef HAVE_NONBLOCK extern void my_context_install_suspend_resume_hook(struct mysql_async_context *b, void (*hook)(my_bool, void *), void *user_data); -#endif uint mysql_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 application when suspending a non-blocking call during automatic reconnect. */ -#ifdef HAVE_NONBLOCK static void my_suspend_hook(my_bool suspend, void *data) { @@ -1548,15 +1543,12 @@ my_suspend_hook(my_bool suspend, void *data) else hook_data->orig_mysql->net.pvio= hook_data->orig_pvio; } -#endif my_bool STDCALL mariadb_reconnect(MYSQL *mysql) { MYSQL tmp_mysql; -#ifdef HAVE_NONBLOCK struct my_hook_data hook_data; struct mysql_async_context *ctxt= NULL; -#endif LIST *li_stmt= mysql->stmts; mysql_init(&tmp_mysql); @@ -1588,7 +1580,6 @@ my_bool STDCALL mariadb_reconnect(MYSQL *mysql) /* don't reread options from configuration files */ tmp_mysql.options.my_cnf_group= tmp_mysql.options.my_cnf_file= NULL; -#ifdef HAVE_NONBLOCK if (IS_MYSQL_ASYNC_ACTIVE(mysql)) { hook_data.orig_mysql= mysql; @@ -1596,17 +1587,14 @@ my_bool STDCALL mariadb_reconnect(MYSQL *mysql) hook_data.orig_pvio= mysql->net.pvio; 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, mysql->db, mysql->port, mysql->unix_socket, mysql->client_flag | CLIENT_REMEMBER_OPTIONS) || mysql_set_character_set(&tmp_mysql, mysql->charset->csname)) { -#ifdef HAVE_NONBLOCK if (ctxt) my_context_install_suspend_resume_hook(ctxt, NULL, NULL); -#endif /* don't free options (CONC-118) */ memset(&tmp_mysql.options, 0, sizeof(struct st_mysql_options)); 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 mysql_get_timeout_value(const MYSQL *mysql) { -#ifdef HAVE_NONBLOCK unsigned int timeout= mysql->options.extension->async_context->timeout_value; /* Avoid overflow. */ if (timeout > UINT_MAX - 999) return (timeout - 1)/1000 + 1; else return (timeout+999)/1000; -#else - return 0; -#endif } unsigned int STDCALL mysql_get_timeout_value_ms(const MYSQL *mysql) { -#ifdef HAVE_NONBLOCK 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) { -#ifdef HAVE_NONBLOCK struct mysql_async_context *ctxt; if ((ctxt = mysql->options.extension->async_context) != 0) { my_context_destroy(&ctxt->async_context); free(ctxt); } -#endif free(mysql->options.extension->plugin_dir); free(mysql->options.extension->default_auth); free(mysql->options.extension->db_driver); @@ -2479,10 +2457,8 @@ mysql_optionsv(MYSQL *mysql,enum mysql_option option, ...) { va_list ap; void *arg1; -#ifdef HAVE_NONBLOCK size_t stacksize; struct mysql_async_context *ctxt; -#endif 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); break; case MYSQL_OPT_NONBLOCK: -#ifdef HAVE_NONBLOCK if (mysql->options.extension && (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; if (mysql->net.pvio) mysql->net.pvio->async_context= ctxt; -#endif break; case MYSQL_OPT_MAX_ALLOWED_PACKET: if (mysql) @@ -3436,13 +3410,11 @@ static my_socket mariadb_get_socket(MYSQL *mysql) pvio handle from async_context until the connection was successfully established. */ -#ifdef HAVE_NONBLOCK else if (mysql->options.extension && mysql->options.extension->async_context && mysql->options.extension->async_context->pvio) { ma_pvio_get_handle(mysql->options.extension->async_context->pvio, &sock); } -#endif return sock; } @@ -3576,15 +3548,10 @@ my_bool STDCALL mariadb_get_infov(MYSQL *mysql, enum mariadb_value value, void * goto error; break; case MARIADB_CONNECTION_ASYNC_TIMEOUT_MS: -#ifdef HAVE_NONBLOCK if (mysql && mysql->options.extension && mysql->options.extension->async_context) *((unsigned int *)arg)= mysql->options.extension->async_context->timeout_value; - else -#endif - goto error; break; case MARIADB_CONNECTION_ASYNC_TIMEOUT: -#ifdef HAVE_NONBLOCK if (mysql && mysql->options.extension && mysql->options.extension->async_context) { 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 *((unsigned int *)arg)= (timeout+999)/1000; } - else -#endif - goto error; break; case MARIADB_CHARSET_NAME: { diff --git a/plugins/pvio/pvio_socket.c b/plugins/pvio/pvio_socket.c index 71022f27..28c34502 100644 --- a/plugins/pvio/pvio_socket.c +++ b/plugins/pvio/pvio_socket.c @@ -29,10 +29,8 @@ #include #include #include -#ifdef HAVE_NONBLOCK #include #include -#endif #include #include #ifndef _WIN32 @@ -65,10 +63,8 @@ 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); 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_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); 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); @@ -91,17 +87,9 @@ struct st_ma_pvio_methods pvio_socket_methods= { pvio_socket_set_timeout, pvio_socket_get_timeout, pvio_socket_read, -#ifdef HAVE_NONBLOCK pvio_socket_async_read, -#else - NULL, -#endif pvio_socket_write, -#ifdef HAVE_NONBLOCK pvio_socket_async_write, -#else - NULL, -#endif pvio_socket_wait_io_or_timeout, pvio_socket_blocking, 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 */ /* read from socket @@ -430,7 +417,6 @@ size_t pvio_socket_async_write(MARIADB_PVIO *pvio, const uchar *buffer, size_t l return r; } /* }}} */ -#endif /* {{{ pvio_socket_write */ /* @@ -738,7 +724,6 @@ static int pvio_socket_connect_sync_or_async(MARIADB_PVIO *pvio, const struct sockaddr *name, uint namelen) { -#ifdef HAVE_NONBLOCK MYSQL *mysql= pvio->mysql; if (mysql->options.extension && mysql->options.extension->async_context && 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); return my_connect_async(pvio, name, namelen, pvio->timeout[PVIO_CONNECT_TIMEOUT]); } -#endif 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); if (!rc) { -#ifdef HAVE_NONBLOCK MYSQL *mysql= pvio->mysql; if (mysql->options.extension && mysql->options.extension->async_context && mysql->options.extension->async_context->active) break; -#endif if (pvio_socket_blocking(pvio, 0, 0) == SOCKET_ERROR) { closesocket(csock->socket); diff --git a/unittest/libmariadb/CMakeLists.txt b/unittest/libmariadb/CMakeLists.txt index c7f4c0c5..038c2cf0 100644 --- a/unittest/libmariadb/CMakeLists.txt +++ b/unittest/libmariadb/CMakeLists.txt @@ -27,9 +27,7 @@ IF(WITH_DYNCOL) SET(API_TESTS ${API_TESTS} "dyncol") ENDIF() -IF(WITH_NONBLCK) - SET(API_TESTS ${API_TESTS} "async") -ENDIF() +SET(API_TESTS ${API_TESTS} "async") #exclude following tests from ctests, since we need to run them maually with different credentials SET(MANUAL_TESTS "t_aurora")