[Commits] 517009ca0fa: MDEV-16548: Innodb fails to start on older kernels that don't support F_DUPFD_CLOEXEC
revision-id: 517009ca0fa5f0e5b48b3d244a0b5bb0c44e90a8 (mariadb-10.1.34-47-g517009ca0fa) parent(s): 3b37edee1a5121e9523fa8a7f483185f402905e2 author: Jan Lindström committer: Jan Lindström timestamp: 2018-08-07 11:35:39 +0300 message: MDEV-16548: Innodb fails to start on older kernels that don't support F_DUPFD_CLOEXEC Add runtime check that fcntl() system call really supports F_DUPFD_CLOEXEC directive. --- storage/innobase/CMakeLists.txt | 27 +++++++++++++++++++++++++++ storage/innobase/handler/ha_innodb.cc | 2 +- storage/xtradb/CMakeLists.txt | 27 +++++++++++++++++++++++++++ storage/xtradb/handler/ha_innodb.cc | 2 +- 4 files changed, 56 insertions(+), 2 deletions(-) diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt index 2a45f05c463..7470f2985c0 100644 --- a/storage/innobase/CMakeLists.txt +++ b/storage/innobase/CMakeLists.txt @@ -246,6 +246,33 @@ IF(HAVE_IB_ATOMIC_PTHREAD_T_GCC) ADD_DEFINITIONS(-DHAVE_IB_ATOMIC_PTHREAD_T_GCC=1) ENDIF() +CHECK_C_SOURCE( +" +#include <unistd.h> +#include <fcntl.h> +#include <stdlib.h> +int main() { + char filename[] = "/tmp/mytemp.XXXXXX"; + int fd = mkstemp(filename); + if (fd != -1) { + int fd2=fcntl(fd, F_DUPFD_CLOEXEC, 0); + if (fd2 != -1) { + close(fd2); + close(fd); + unlink(filename); + return (0); + } + close (fd); + unlink(filename); + } + return (1); +}" +HAVE_IB_F_DUPFD_CLOEXEC) + +IF (HAVE_IB_F_DUPFD_CLOEXEC) + ADD_DEFINITIONS(-DHAVE_IB_F_DUPFD_CLOEXEC=1) +ENDIF() + CHECK_C_SOURCE_COMPILES("struct t1{ int a; char *b; }; struct t1 c= { .a=1, .b=0 }; main() { }" HAVE_C99_INITIALIZERS) ENDIF(NOT MSVC) diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 5667efea5df..6843d90b0a9 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -2414,7 +2414,7 @@ innobase_mysql_tmpfile( } } #else -#ifdef F_DUPFD_CLOEXEC +#if defined(F_DUPFD_CLOEXEC) && defined(HAVE_IB_F_DUPFD_CLOEXEC) fd2 = fcntl(fd, F_DUPFD_CLOEXEC, 0); #else fd2 = dup(fd); diff --git a/storage/xtradb/CMakeLists.txt b/storage/xtradb/CMakeLists.txt index f5ec6fd746d..5ec5881a247 100644 --- a/storage/xtradb/CMakeLists.txt +++ b/storage/xtradb/CMakeLists.txt @@ -255,6 +255,33 @@ IF(HAVE_IB_ATOMIC_PTHREAD_T_GCC) ADD_DEFINITIONS(-DHAVE_IB_ATOMIC_PTHREAD_T_GCC=1) ENDIF() +CHECK_C_SOURCE( +" +#include <unistd.h> +#include <fcntl.h> +#include <stdlib.h> +int main() { + char filename[] = "/tmp/mytemp.XXXXXX"; + int fd = mkstemp(filename); + if (fd != -1) { + int fd2=fcntl(fd, F_DUPFD_CLOEXEC, 0); + if (fd2 != -1) { + close(fd2); + close(fd); + unlink(filename); + return (0); + } + close (fd); + unlink(filename); + } + return (1); +}" +HAVE_IB_F_DUPFD_CLOEXEC) + +IF (HAVE_IB_F_DUPFD_CLOEXEC) + ADD_DEFINITIONS(-DHAVE_IB_F_DUPFD_CLOEXEC=1) +ENDIF() + CHECK_C_SOURCE_COMPILES("struct t1{ int a; char *b; }; struct t1 c= { .a=1, .b=0 }; main() { }" HAVE_C99_INITIALIZERS) ENDIF(NOT MSVC) diff --git a/storage/xtradb/handler/ha_innodb.cc b/storage/xtradb/handler/ha_innodb.cc index 3cd7cb6977b..fd62bc00ca4 100644 --- a/storage/xtradb/handler/ha_innodb.cc +++ b/storage/xtradb/handler/ha_innodb.cc @@ -2738,7 +2738,7 @@ innobase_mysql_tmpfile( } } #else -#ifdef F_DUPFD_CLOEXEC +#if defined(F_DUPFD_CLOEXEC) && defined(HAVE_IB_F_DUPFD_CLOEXEC) fd2 = fcntl(fd, F_DUPFD_CLOEXEC, 0); #else fd2 = dup(fd);
participants (1)
-
jan