Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

httping: fix build on < 10.11 #25943

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions net/httping/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are changing the depends_lib dependencies so that requires to increase the revision

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
Copy link
Contributor

@reneeotten reneeotten Sep 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's wait and see what the outcome is from the discussion with upstream as we don't want to carry patched like this.


configure.args -DCMAKE_EXE_LINKER_FLAGS="-lintl"

destroot {
Expand Down
115 changes: 115 additions & 0 deletions net/httping/files/0001-Define-NO_TFO-on-macOS-10.11.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
From c5acacdf6503797e47772f00c744bb03476be2c4 Mon Sep 17 00:00:00 2001
From: Sergey Fedorov <[email protected]>
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 <AvailabilityMacros.h>
+#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;