From 33ff6a95acb52f29c4a2e7a8e10d99f298f2e701 Mon Sep 17 00:00:00 2001 From: Sara Dickinson Date: Fri, 18 Aug 2017 17:59:49 +0100 Subject: [PATCH] Fix issue on macOX 10.10 where TCP fast open is detected but not implemented causing TCP to fail. The fix allows fallback to regular TCP in this case and is also more robust for cases where connectx() fails for some reason. --- src/stub.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/stub.c b/src/stub.c index b8ac6710..de8121dd 100644 --- a/src/stub.c +++ b/src/stub.c @@ -425,15 +425,14 @@ tcp_connect(getdns_upstream *upstream, getdns_transport_list_t transport) endpoints.sae_srcaddrlen = 0; endpoints.sae_dstaddr = (struct sockaddr *)&upstream->addr; endpoints.sae_dstaddrlen = upstream->addr_len; - if (connectx(fd, &endpoints, SAE_ASSOCID_ANY, + if (connectx(fd, &endpoints, SAE_ASSOCID_ANY, CONNECT_DATA_IDEMPOTENT | CONNECT_RESUME_ON_READ_WRITE, - NULL, 0, NULL, NULL) == -1) { - if (errno != EINPROGRESS) { - close(fd); - return -1; - } + NULL, 0, NULL, NULL) == 0) { + return fd; + } + if (errno == EINPROGRESS) { + return fd; } - return fd; #else (void)transport; #endif