From d47f2d5cc9d790c28c8041d7c6b3ba3242a81f71 Mon Sep 17 00:00:00 2001 From: Ryan Beasley Date: Thu, 11 Apr 2019 10:29:21 -0700 Subject: [PATCH] include linux/tcp.h on Linux pre-glibc 2.17 Bazel 0.24.0 upgraded grpc from 1.13.0 to 1.18.0, and the latter makes use of the TCP_USER_TIMEOUT socket option. Problem: grpc conditions the option on the Linux kernel version but sources the option from glibc's `netinet/tcp.h`. glibc != Linux kernel, and that option wasn't imported to glibc until 2.17. We can't just build Bazel with glibc 2.17 because we still have to support CentOS 6 dev nodes which ship with glibc 2.12. So instead this change tweaks the grpc headers to conditionally include instead of . Resolves https://github.com/grpc/grpc/issues/18728. --- src/core/lib/iomgr/port.h | 9 +++++++++ src/core/lib/iomgr/socket_utils_common_posix.cc | 4 ++++ 2 files changed, 13 insertions(+) diff --git a/src/core/lib/iomgr/port.h b/src/core/lib/iomgr/port.h index ccb4c31e8c9..d387de5b13c 100644 --- a/src/core/lib/iomgr/port.h +++ b/src/core/lib/iomgr/port.h @@ -88,6 +88,15 @@ #ifdef LINUX_VERSION_CODE #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37) #define GRPC_HAVE_TCP_USER_TIMEOUT +#ifdef __GLIBC_PREREQ +#if !(__GLIBC_PREREQ(2, 17)) +/* + * TCP_USER_TIMEOUT wasn't imported to glibc until 2.17. Use Linux system + * header instead. + */ +#define GRPC_LINUX_TCP_H 1 +#endif /* __GLIBC_PREREQ(2, 17) */ +#endif /* ifdef __GLIBC_PREREQ */ #endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37) */ #endif /* LINUX_VERSION_CODE */ #ifndef __GLIBC__ diff --git a/src/core/lib/iomgr/socket_utils_common_posix.cc b/src/core/lib/iomgr/socket_utils_common_posix.cc index 4c337a05210..ea0adb1f6a6 100644 --- a/src/core/lib/iomgr/socket_utils_common_posix.cc +++ b/src/core/lib/iomgr/socket_utils_common_posix.cc @@ -30,7 +30,11 @@ #include #include #include +#ifdef GRPC_LINUX_TCP_H +#include +#else #include +#endif #include #include #include