Skip to content

Commit 00c84af

Browse files
authored
Merge pull request #163 from git-for-windows/happy-eyeballs-fix-for-curl
Fix the cURL problem identified in `microsoft/git` via t5799.13(curl-connect: no server) failures
2 parents 86f2369 + 4d8f15b commit 00c84af

2 files changed

Lines changed: 111 additions & 4 deletions

File tree

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
From 271add6fc90245bd99448357b4f5a76598eb3e85 Mon Sep 17 00:00:00 2001
2+
From: Stefan Eissing <stefan@eissing.org>
3+
Date: Mon, 29 Sep 2025 16:38:55 +0200
4+
Subject: [PATCH] ip-happy: do not set unnecessary timeout
5+
6+
When attempts on all addresses have been started, do
7+
no longer set any EXPIRE_HAPPY_EYEBALLS timeouts.
8+
9+
refs #18767
10+
---
11+
lib/cf-ip-happy.c | 43 ++++++++++++++++++++++++++++++-------------
12+
1 file changed, 30 insertions(+), 13 deletions(-)
13+
14+
diff --git a/lib/cf-ip-happy.c b/lib/cf-ip-happy.c
15+
index 0a1364e4b..801370fd9 100644
16+
--- a/lib/cf-ip-happy.c
17+
+++ b/lib/cf-ip-happy.c
18+
@@ -156,6 +156,18 @@ static const struct Curl_addrinfo *cf_ai_iter_next(struct cf_ai_iter *iter)
19+
return iter->last;
20+
}
21+
22+
+static bool cf_ai_iter_has_more(struct cf_ai_iter *iter)
23+
+{
24+
+ const struct Curl_addrinfo *addr = iter->last ? iter->last->ai_next :
25+
+ ((iter->n < 0) ? iter->head : NULL);
26+
+ while(addr) {
27+
+ if(addr->ai_family == iter->ai_family)
28+
+ return TRUE;
29+
+ addr = addr->ai_next;
30+
+ }
31+
+ return FALSE;
32+
+}
33+
+
34+
#ifdef USE_IPV6
35+
static bool cf_ai_iter_done(struct cf_ai_iter *iter)
36+
{
37+
@@ -356,7 +368,7 @@ static CURLcode cf_ip_ballers_run(struct cf_ip_ballers *bs,
38+
{
39+
CURLcode result = CURLE_OK;
40+
struct cf_ip_attempt *a = NULL, **panchor;
41+
- bool do_more, more_possible;
42+
+ bool do_more;
43+
struct curltime now;
44+
timediff_t next_expire_ms;
45+
int i, inconclusive, ongoing;
46+
@@ -367,7 +379,6 @@ static CURLcode cf_ip_ballers_run(struct cf_ip_ballers *bs,
47+
evaluate:
48+
now = curlx_now();
49+
ongoing = inconclusive = 0;
50+
- more_possible = TRUE;
51+
52+
/* check if a running baller connects now */
53+
i = -1;
54+
@@ -475,11 +486,8 @@ evaluate:
55+
/* attempt timeout for restart has not expired yet */
56+
goto out;
57+
}
58+
- else if(ongoing) {
59+
+ else if(!ongoing) {
60+
/* no more addresses, no inconclusive attempts */
61+
- more_possible = FALSE;
62+
- }
63+
- else {
64+
CURL_TRC_CF(data, cf, "no more attempts to try");
65+
result = CURLE_COULDNT_CONNECT;
66+
i = 0;
67+
@@ -493,21 +501,30 @@ evaluate:
68+
69+
out:
70+
if(!result) {
71+
+ bool more_possible;
72+
+
73+
/* when do we need to be called again? */
74+
next_expire_ms = Curl_timeleft(data, &now, TRUE);
75+
+ if(next_expire_ms <= 0) {
76+
+ failf(data, "Connection timeout after %" FMT_OFF_T " ms",
77+
+ curlx_timediff(now, data->progress.t_startsingle));
78+
+ return CURLE_OPERATION_TIMEDOUT;
79+
+ }
80+
+
81+
+ more_possible = cf_ai_iter_has_more(&bs->addr_iter);
82+
+#ifdef USE_IPV6
83+
+ if(!more_possible)
84+
+ more_possible = cf_ai_iter_has_more(&bs->ipv6_iter);
85+
+#endif
86+
if(more_possible) {
87+
timediff_t expire_ms, elapsed_ms;
88+
elapsed_ms = curlx_timediff(now, bs->last_attempt_started);
89+
expire_ms = CURLMAX(bs->attempt_delay_ms - elapsed_ms, 0);
90+
next_expire_ms = CURLMIN(next_expire_ms, expire_ms);
91+
+ CURL_TRC_CF(data, cf, "next HAPPY_EYBALLS timeout in %" FMT_TIMEDIFF_T
92+
+ "ms", next_expire_ms);
93+
+ Curl_expire(data, next_expire_ms, EXPIRE_HAPPY_EYEBALLS);
94+
}
95+
-
96+
- if(next_expire_ms <= 0) {
97+
- failf(data, "Connection timeout after %" FMT_OFF_T " ms",
98+
- curlx_timediff(now, data->progress.t_startsingle));
99+
- return CURLE_OPERATION_TIMEDOUT;
100+
- }
101+
- Curl_expire(data, next_expire_ms, EXPIRE_HAPPY_EYEBALLS);
102+
}
103+
return result;
104+
}

mingw-w64-curl/PKGBUILD

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}"
66
"${MINGW_PACKAGE_PREFIX}-${_realname}-gnutls"
77
"${MINGW_PACKAGE_PREFIX}-${_realname}-winssl")
88
pkgver=8.16.0
9-
pkgrel=1
9+
pkgrel=2
1010
pkgdesc="Command line tool and library for transferring data with URLs (mingw-w64)"
1111
arch=('any')
1212
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
@@ -35,13 +35,15 @@ source=("https://github.com/curl/curl/releases/download/${_realname}-${pkgver//.
3535
"pathtools.c"
3636
"pathtools.h"
3737
"0001-Make-cURL-relocatable.patch"
38-
"0002-Hack-make-relocation-work-inside-libexec-git-core-an.patch")
38+
"0002-Hack-make-relocation-work-inside-libexec-git-core-an.patch"
39+
"0003-ip-happy-do-not-set-unnecessary-timeout.patch")
3940
sha256sums=('9459180ab4933b30d0778ddd71c91fe2911fab731c46e59b3f4c8385b1596c91'
4041
'SKIP'
4142
'08209cbf1633fa92eae7e5d28f95f8df9d6184cc20fa878c99aec4709bb257fd'
4243
'965d3921ec4fdeec94a2718bc2c85ce5e1a00ea0e499330a554074a7ae15dfc6'
4344
'8aa4eab2f2c38afb0ae7825be5be032194574f08cedd37b57b9ea5a19eb25ad4'
44-
'c43eb97757f71a5f2368fa1b132d286e8ceb91060742e643d4dbc06712a57e94')
45+
'c43eb97757f71a5f2368fa1b132d286e8ceb91060742e643d4dbc06712a57e94'
46+
'90de3265dc33894fe53fb2b0c0ffd25e1fae0330d2a5e00ebafb3cb34c2e7591')
4547
validpgpkeys=('27EDEAF22F3ABCEB50DB9A125CC908FDB71E12C2') # Daniel Stenberg
4648

4749
if test -z "$WITHOUT_ALTERNATES"
@@ -91,7 +93,8 @@ prepare() {
9193

9294
apply_patch_with_msg \
9395
0001-Make-cURL-relocatable.patch \
94-
0002-Hack-make-relocation-work-inside-libexec-git-core-an.patch
96+
0002-Hack-make-relocation-work-inside-libexec-git-core-an.patch \
97+
0003-ip-happy-do-not-set-unnecessary-timeout.patch
9598

9699
autoreconf -vfi
97100
}

0 commit comments

Comments
 (0)