summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVladislav Vaintroub <wlad@montyprogram.com>2013-06-15 14:22:03 +0200
committerVladislav Vaintroub <wlad@montyprogram.com>2013-06-15 14:22:03 +0200
commit4b058643cd6396b46898380ba7fee5d583e18cfd (patch)
treea3fc883411b6d6d56b3250d6ce43e0b9096bcefc
parentb54a4b7621b4bdcc9846a968e4268ea71e88dab8 (diff)
downloadmariadb-git-4b058643cd6396b46898380ba7fee5d583e18cfd.tar.gz
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.
-rw-r--r--client/mysqltest.cc9
-rw-r--r--cmake/os/WindowsCache.cmake2
-rw-r--r--config.h.cmake1
-rw-r--r--configure.cmake1
-rw-r--r--include/my_context.h11
-rw-r--r--mysys/my_context.c34
-rw-r--r--tests/mysql_client_fw.c3
7 files changed, 56 insertions, 5 deletions
diff --git a/client/mysqltest.cc b/client/mysqltest.cc
index 2dde607a016..e2846994c5a 100644
--- a/client/mysqltest.cc
+++ b/client/mysqltest.cc
@@ -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);
diff --git a/cmake/os/WindowsCache.cmake b/cmake/os/WindowsCache.cmake
index 83ea3b0f3b3..2a6fb5ae31f 100644
--- a/cmake/os/WindowsCache.cmake
+++ b/cmake/os/WindowsCache.cmake
@@ -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()
diff --git a/config.h.cmake b/config.h.cmake
index f8fa5093bbf..8c28b997f87 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -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
diff --git a/configure.cmake b/configure.cmake
index db2779a2bf9..13a06e6d159 100644
--- a/configure.cmake
+++ b/configure.cmake
@@ -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)
diff --git a/include/my_context.h b/include/my_context.h
index 1e1b7e6a749..8ed0c0ccf4e 100644
--- a/include/my_context.h
+++ b/include/my_context.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.
diff --git a/mysys/my_context.c b/mysys/my_context.c
index 08dc0920f21..9be5ab80468 100644
--- a/mysys/my_context.c
+++ b/mysys/my_context.c
@@ -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
diff --git a/tests/mysql_client_fw.c b/tests/mysql_client_fw.c
index 207eaead135..9ce4737d874 100644
--- a/tests/mysql_client_fw.c
+++ b/tests/mysql_client_fw.c
@@ -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