Commit 4b058643 authored by Vladislav Vaintroub's avatar Vladislav Vaintroub

MDEV-4601 : Allow MariaDB to be build without non-blocking client.

Non-blocking client currently can be build on Windows, GCC on i386 and x64, or any OS wth ucontext.h header. Prior to this patch, build failed if neither of these conditions is true.
Fix to avoid compiler errors in these case - non-blocking API would not be useful on , but otherwise everything will work as before.
parent b54a4b76
......@@ -63,8 +63,9 @@
#define SIGNAL_FMT "signal %d"
#endif
#include <my_context.h>
static my_bool non_blocking_api_enabled= 0;
#if !defined(EMBEDDED_LIBRARY)
#if !defined(EMBEDDED_LIBRARY) && !defined(MY_CONTEXT_DISABLE)
#define WRAP_NONBLOCK_ENABLED non_blocking_api_enabled
#include "../tests/nonblock-wrappers.h"
#endif
......@@ -5932,8 +5933,10 @@ void do_connect(struct st_command *command)
if (opt_connect_timeout)
mysql_options(con_slot->mysql, MYSQL_OPT_CONNECT_TIMEOUT,
(void *) &opt_connect_timeout);
mysql_options(con_slot->mysql, MYSQL_OPT_NONBLOCK, 0);
#ifndef MY_CONTEXT_DISABLE
if (mysql_options(con_slot->mysql, MYSQL_OPT_NONBLOCK, 0))
die("Failed to initialise non-blocking API");
#endif
if (opt_compress || con_compress)
mysql_options(con_slot->mysql, MYSQL_OPT_COMPRESS, NullS);
mysql_options(con_slot->mysql, MYSQL_OPT_LOCAL_INFILE, 0);
......
......@@ -368,4 +368,6 @@ SET(HAVE_EVENT_H CACHE INTERNAL "")
SET(HAVE_LINUX_UNISTD_H CACHE INTERNAL "")
SET(HAVE_SYS_UTSNAME_H CACHE INTERNAL "")
SET(HAVE_PTHREAD_ATTR_GETGUARDSIZE CACHE INTERNAL "")
SET(HAVE_UCONTEXT_H CACHE INTERNAL "")
SET(HAVE_SOCKPEERCRED CACHE INTERNAL "")
ENDIF()
......@@ -291,6 +291,7 @@
#cmakedefine HAVE_THR_YIELD 1
#cmakedefine HAVE_TIME 1
#cmakedefine HAVE_TIMES 1
#cmakedefine HAVE_UCONTEXT 1
#cmakedefine HAVE_VALLOC 1
#cmakedefine HAVE_VIDATTR 1
#define HAVE_VIO_READ_BUFF 1
......
......@@ -1102,3 +1102,4 @@ SET(CMAKE_EXTRA_INCLUDE_FILES)
CHECK_STRUCT_HAS_MEMBER("struct dirent" d_ino "dirent.h" STRUCT_DIRENT_HAS_D_INO)
CHECK_STRUCT_HAS_MEMBER("struct dirent" d_namlen "dirent.h" STRUCT_DIRENT_HAS_D_NAMLEN)
SET(SPRINTF_RETURNS_INT 1)
CHECK_INCLUDE_FILE(ucontext.h HAVE_UCONTEXT_H)
......@@ -31,8 +31,10 @@
#define MY_CONTEXT_USE_X86_64_GCC_ASM
#elif defined(__GNUC__) && __GNUC__ >= 3 && defined(__i386__)
#define MY_CONTEXT_USE_I386_GCC_ASM
#else
#elif defined(HAVE_UCONTEXT)
#define MY_CONTEXT_USE_UCONTEXT
#else
#define MY_CONTEXT_DISABLE
#endif
#ifdef MY_CONTEXT_USE_WIN32_FIBERS
......@@ -104,6 +106,13 @@ struct my_context {
#endif
#ifdef MY_CONTEXT_DISABLE
struct my_context {
int dummy;
};
#endif
/*
Initialize an asynchroneous context object.
Returns 0 on success, non-zero on failure.
......
......@@ -726,3 +726,37 @@ my_context_continue(struct my_context *c)
}
#endif /* MY_CONTEXT_USE_WIN32_FIBERS */
#ifdef MY_CONTEXT_DISABLE
int
my_context_continue(struct my_context *c)
{
return -1;
}
int
my_context_spawn(struct my_context *c, void (*f)(void *), void *d)
{
return -1;
}
int
my_context_yield(struct my_context *c)
{
return -1;
}
int
my_context_init(struct my_context *c, size_t stack_size)
{
return -1; /* Out of memory */
}
void
my_context_destroy(struct my_context *c)
{
}
#endif
......@@ -30,8 +30,9 @@
and use poll()/select() to wait for them to complete. This way we can get
a good coverage testing of the non-blocking API as well.
*/
#include <my_context.h>
static my_bool non_blocking_api_enabled= 0;
#if !defined(EMBEDDED_LIBRARY)
#if !defined(EMBEDDED_LIBRARY) && !defined(MY_CONTEXT_DISABLE)
#define WRAP_NONBLOCK_ENABLED non_blocking_api_enabled
#include "nonblock-wrappers.h"
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment