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