From a449dde8a7aa060bb7ac20841ee8181857b8a756 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Fri, 7 Aug 2026 03:15:59 +0000 Subject: [PATCH 09/38] networking: drop connectx() fast path on Apple, always use sendto() connectx() isn't available on legacy macOS/PowerPC; fall back to the same sendto()-based TFO path used on Linux everywhere. Ported from https://github.com/macos-powerpc/powerpc-ports/blob/main/sysutils/fastfetch/files/0014-unbreak-common-networking.patch --- src/common/impl/networking_linux.c | 42 ------------------------------ 1 file changed, 42 deletions(-) diff --git a/src/common/impl/networking_linux.c b/src/common/impl/networking_linux.c index 770c0ce77..730b53ade 100644 --- a/src/common/impl/networking_linux.c +++ b/src/common/impl/networking_linux.c @@ -55,7 +55,6 @@ static const char* tryNonThreadingFastPath(FFNetworkingState* state) { #endif } - #ifndef __APPLE__ FF_DEBUG("Using sendto() " #ifdef MSG_FASTOPEN "+ MSG_FASTOPEN " @@ -76,35 +75,6 @@ static const char* tryNonThreadingFastPath(FFNetworkingState* state) { 0, state->addr->ai_addr, state->addr->ai_addrlen); - #else - if (fcntl(state->sockfd, F_SETFL, O_NONBLOCK) == -1) { - FF_DEBUG("fcntl(F_SETFL) failed: %s", strerror(errno)); - return "fcntl(F_SETFL) failed"; - } - FF_DEBUG("Using connectx() to send %u bytes of data", state->command.length); - // Use connectx to establish connection and send data in one call - size_t sent; - if (connectx(state->sockfd, - &(sa_endpoints_t) { - .sae_dstaddr = state->addr->ai_addr, - .sae_dstaddrlen = state->addr->ai_addrlen, - }, - SAE_ASSOCID_ANY, - state->tfo ? CONNECT_DATA_IDEMPOTENT : 0, - &(struct iovec) { - .iov_base = state->command.chars, - .iov_len = state->command.length, - }, - 1, - &sent, - nullptr) != 0) { - sent = 0; - } - if (fcntl(state->sockfd, F_SETFL, 0) == -1) { - FF_DEBUG("fcntl(F_SETFL) failed: %s", strerror(errno)); - return "fcntl(F_SETFL) failed"; - } - #endif if (sent > 0 || (errno == EAGAIN || errno == EWOULDBLOCK #ifdef __APPLE__ // On macOS EINPROGRESS means the connection cannot be completed immediately @@ -113,11 +83,7 @@ static const char* tryNonThreadingFastPath(FFNetworkingState* state) { #endif )) { FF_DEBUG( - #ifdef __APPLE__ - "connectx()" - #else "sendto()" - #endif " %s (sent=%zd, %s)", errno == 0 ? "succeeded" : "was in progress", sent, @@ -129,18 +95,10 @@ static const char* tryNonThreadingFastPath(FFNetworkingState* state) { } FF_DEBUG( - #ifdef __APPLE__ - "connectx()" - #else "sendto()" - #endif " failed: %s", strerror(errno)); - #ifdef __APPLE__ - return "connectx() failed"; - #else return "sendto() failed"; - #endif #else FF_UNUSED(state); return "TFO support is not available"; -- 2.43.0