Created
January 15, 2019 21:39
-
-
Save AmarOk1412/bf4e5b8a534e55a1759691f9c857ade4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
configure.ac | 39 +++++++++++++++++++++++++++++++++++++++ | |
lib/system/fastopen.c | 4 ++-- | |
2 files changed, 41 insertions(+), 2 deletions(-) | |
diff --git a/configure.ac b/configure.ac | |
index e81ff8970..b25778a83 100644 | |
--- a/configure.ac | |
+++ b/configure.ac | |
@@ -127,6 +127,45 @@ case "$host" in | |
AC_MSG_CHECKING([whether the linker supports -Wl,-no_weak_imports]) | |
AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], | |
[AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no); LDFLAGS="$save_LDFLAGS"]) | |
+ | |
+ dnl CURL_CHECK_FUNC_CONNECTX | |
+ dnl | |
+ dnl Check if connectx() function is present. | |
+ dnl The connectx() function call appeared in Darwin 15.0.0 | |
+ dnl but it's not declared using availability attribute. | |
+ dnl Additionally _connectx symbol is part of OS X 10.9/10.10 | |
+ dnl system lib but does not have specified functionality. | |
+ dnl | |
+ | |
+ AC_DEFUN([CURL_CHECK_FUNC_CONNECTX], [ | |
+ AC_REQUIRE([CURL_MAC_CFLAGS])dnl | |
+ AC_CHECK_FUNCS([connectx]) | |
+ AC_MSG_CHECKING([if connectx is available in deployment target]) | |
+ AC_COMPILE_IFELSE( | |
+ [AC_LANG_PROGRAM([[ | |
+ #if defined(HAVE_CONNECTX) | |
+ # include <Availability.h> | |
+ # if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) | |
+ # if (__MAC_OS_X_VERSION_MIN_REQUIRED < 101100) | |
+ # error Function requires deployment target OS X 10.11 or later | |
+ # endif | |
+ # elif defined(__IPHONE_OS_VERSION_MIN_REQUIRED) | |
+ # if (__IPHONE_OS_VERSION_MIN_REQUIRED < 90000) | |
+ # error Function requires deployment target iOS 9.0 or later | |
+ # endif | |
+ # endif | |
+ #else | |
+ # error Function not present in the headers | |
+ #endif | |
+ ]])], | |
+ [ | |
+ AC_DEFINE(HAVE_VALID_CONNECTX, 1, | |
+ [Set to 1 if connectx() function have specified functionality.]) | |
+ AC_MSG_RESULT([yes]) | |
+ ], | |
+ [AC_MSG_RESULT([no])] | |
+ ) | |
+ ]) | |
;; | |
*solaris*) | |
have_elf=yes | |
diff --git a/lib/system/fastopen.c b/lib/system/fastopen.c | |
index 0f673b7c4..2f61b1c28 100644 | |
--- a/lib/system/fastopen.c | |
+++ b/lib/system/fastopen.c | |
@@ -126,8 +126,8 @@ tfo_writev(gnutls_transport_ptr_t ptr, const giovec_t * iovec, int iovec_cnt) | |
if (ret == 0) | |
p->connect_only = 0; | |
} | |
-# elif defined(TCP_FASTOPEN_OSX) | |
- { | |
+# elif defined(TCP_FASTOPEN_OSX) && HAVE_VALID_CONNECTX | |
+ { | |
sa_endpoints_t endpoints = { .sae_dstaddr = (struct sockaddr*)&p->connect_addr, .sae_dstaddrlen = p->connect_addrlen }; | |
ret = connectx(fd, &endpoints, SAE_ASSOCID_ANY, CONNECT_RESUME_ON_READ_WRITE | CONNECT_DATA_IDEMPOTENT, NULL, 0, NULL, NULL); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment