From 4f4f2a71956b3f6578541c39ea62cf95a2663486 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Fri, 27 Sep 2024 00:52:50 +0800 Subject: [PATCH] httping: fix build on < 10.11 Closes: https://trac.macports.org/ticket/70146 --- net/httping/Portfile | 15 ++- .../0001-Define-NO_TFO-on-macOS-10.11.patch | 115 ++++++++++++++++++ 2 files changed, 126 insertions(+), 4 deletions(-) create mode 100644 net/httping/files/0001-Define-NO_TFO-on-macOS-10.11.patch diff --git a/net/httping/Portfile b/net/httping/Portfile index dfaa623bc455e..3ef1717a12d98 100644 --- a/net/httping/Portfile +++ b/net/httping/Portfile @@ -3,6 +3,7 @@ PortSystem 1.0 PortGroup cmake 1.1 PortGroup github 1.0 +PortGroup openssl 1.0 github.setup folkertvanheusden HTTPing 3.6 v revision 0 @@ -27,15 +28,21 @@ long_description Give it an url, and it will show you how long it takes to \ github.tarball_from archive -depends_lib port:fftw-3 \ - port:gettext \ - port:ncurses \ - path:lib/libssl.dylib:openssl +depends_build-append \ + port:gettext + +depends_lib-append port:fftw-3 \ + port:gettext-runtime \ + port:ncurses installs_libs no patchfiles patch-tcp.c.diff +# https://trac.macports.org/ticket/70146 +# https://github.com/folkertvanheusden/HTTPing/pull/22 +patchfiles-append 0001-Define-NO_TFO-on-macOS-10.11.patch + configure.args -DCMAKE_EXE_LINKER_FLAGS="-lintl" destroot { diff --git a/net/httping/files/0001-Define-NO_TFO-on-macOS-10.11.patch b/net/httping/files/0001-Define-NO_TFO-on-macOS-10.11.patch new file mode 100644 index 0000000000000..14d86a59ee10e --- /dev/null +++ b/net/httping/files/0001-Define-NO_TFO-on-macOS-10.11.patch @@ -0,0 +1,115 @@ +From c5acacdf6503797e47772f00c744bb03476be2c4 Mon Sep 17 00:00:00 2001 +From: Sergey Fedorov +Date: Fri, 27 Sep 2024 00:36:42 +0800 +Subject: [PATCH] Define NO_TFO on macOS < 10.11 + +--- + gen.h | 7 +++++++ + help.c | 4 ++++ + main.c | 8 +++++++- + tcp.c | 7 +++++++ + 4 files changed, 25 insertions(+), 1 deletion(-) + +diff --git gen.h gen.h +index 68a0e9b..9fe7a07 100644 +--- gen.h ++++ gen.h +@@ -34,6 +34,13 @@ + #define gettext(x) (x) + #endif + ++#ifdef __APPLE__ ++#include ++#if MAC_OS_X_VERSION_MIN_REQUIRED < 101100 ++#define NO_TFO ++#endif ++#endif ++ + typedef struct + { + double cur, min, avg, max, sd, med; +diff --git help.c help.c +index 3eddb55..3d507f0 100644 +--- help.c ++++ help.c +@@ -71,7 +71,9 @@ void version(void) + #endif + #endif + ++#ifndef NO_TFO + fprintf(stderr, gettext(" * TFO (TCP fast open) support included (-F)\n")); ++#endif + fprintf(stderr, gettext("\n")); + } + +@@ -207,7 +209,9 @@ void usage(const char *me) + format_help("-r", "--resolve-once", gettext("resolve hostname only once (useful when pinging roundrobin DNS: also takes the first DNS lookup out of the loop so that the first measurement is also correct)")); + format_help("-W", NULL, gettext("do not abort the program if resolving failed: keep retrying")); + format_help("-y x", "--bind-to", gettext("bind to an ip-address (and thus interface) with an optional port")); ++#ifndef NO_TFO + format_help("-F", "--tcp-fast-open", gettext("\"TCP fast open\" (TFO), reduces the latency of TCP connects")); ++#endif + #ifdef linux + format_help(NULL, "--priority", gettext("set priority of packets")); + #endif +diff --git main.c main.c +index 4b44b26..39ab05d 100644 +--- main.c ++++ main.c +@@ -1396,7 +1396,11 @@ int main(int argc, char *argv[]) + break; + + case 'F': ++#ifdef NO_TFO ++ fprintf(stderr, gettext("Warning: TCP TFO is not supported. Disabling.\n")); ++#else + use_tfo = 1; ++#endif + break; + + case 22: +@@ -2157,7 +2161,7 @@ persistent_loop: + #if defined(linux) || defined(__FreeBSD__) + if (getsockopt(fd, IPPROTO_TCP, TCP_INFO, &info, &info_len) == 0) + { +-#ifdef TCPI_OPT_SYN_DATA ++#if defined(TCPI_OPT_SYN_DATA) && !defined(NO_TFO) + if (info.tcpi_options & TCPI_OPT_SYN_DATA) + tfo_success = 1; + #endif +@@ -2345,8 +2349,10 @@ persistent_loop: + #endif + } + ++#ifndef NO_TFO + if (tfo_success) + str_add(&line, " F"); ++#endif + + #if HAVE_NCURSES + if (ncurses_mode) +diff --git tcp.c tcp.c +index 9f95c39..11df814 100644 +--- tcp.c ++++ tcp.c +@@ -159,6 +159,12 @@ int connect_to(int fd, struct addrinfo *ai, double timeout, char *tfo, char *msg + to.tv_usec = (long)(timeout * 1000.0) % 1000000; + + /* connect to peer */ ++#ifdef NO_TFO ++ (void)tfo; ++ (void)msg; ++ (void)msg_len; ++ (void)msg_accepted; ++#else + if (tfo && *tfo) + { + #if defined(__FreeBSD__) +@@ -182,6 +188,7 @@ int connect_to(int fd, struct addrinfo *ai, double timeout, char *tfo, char *msg + } + } + else ++#endif + { + int rc = -1; +