aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Yash Tibrewal <yashkt@google.com>2018-08-21 17:07:33 -0700
committerGravatar Yash Tibrewal <yashkt@google.com>2018-08-21 17:07:33 -0700
commitecee4ac703e909b4edd789e137e3b0b736dfe37a (patch)
tree436c1ba74da989857cca3e5e05099e5b9a4c18d4
parent2f8e60a7737293a3e44f555ac9de92267785e91f (diff)
Use linux kernel version 2.6.37 to decide whether to use TCP_USER_TIMEOUT or not
-rw-r--r--src/core/lib/iomgr/port.h6
-rw-r--r--src/core/lib/iomgr/socket_utils_common_posix.cc4
2 files changed, 8 insertions, 2 deletions
diff --git a/src/core/lib/iomgr/port.h b/src/core/lib/iomgr/port.h
index 066417b93c..bc58ed13c0 100644
--- a/src/core/lib/iomgr/port.h
+++ b/src/core/lib/iomgr/port.h
@@ -77,6 +77,12 @@
#define GRPC_LINUX_SOCKETUTILS 1
#endif
#endif
+#include <linux/version.h>
+#ifdef LINUX_VERSION_CODE
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37)
+#define GRPC_HAVE_TCP_USER_TIMEOUT
+#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 37) */
+#endif /* LINUX_VERSION_CODE */
#ifndef __GLIBC__
#define GRPC_LINUX_EPOLL 1
#define GRPC_LINUX_EPOLL_CREATE1 1
diff --git a/src/core/lib/iomgr/socket_utils_common_posix.cc b/src/core/lib/iomgr/socket_utils_common_posix.cc
index 8b8e303ef7..5dc8fcb427 100644
--- a/src/core/lib/iomgr/socket_utils_common_posix.cc
+++ b/src/core/lib/iomgr/socket_utils_common_posix.cc
@@ -226,7 +226,7 @@ grpc_error* grpc_set_socket_low_latency(int fd, int low_latency) {
/* Set TCP_USER_TIMEOUT */
grpc_error* grpc_set_socket_tcp_user_timeout(int fd, int val) {
-#ifdef GPR_LINUX
+#ifdef GRPC_HAVE_TCP_USER_TIMEOUT
int newval;
socklen_t len;
if (val == 0) {
@@ -242,7 +242,7 @@ grpc_error* grpc_set_socket_tcp_user_timeout(int fd, int val) {
return GRPC_ERROR_CREATE_FROM_STATIC_STRING(
"Failed to set TCP_USER_TIMEOUT");
}
-#endif /* GPR_LINUX */
+#endif /* GRPC_HAVE_TCP_USER_TIMEOUT */
return GRPC_ERROR_NONE;
}