Skip to content

Commit 6523961

Browse files
authored
Fix very long t5799-gvfs-helper.sh runtimes in our CI runs (#760)
I have noticed for over a year now that some jobs in `microsoft/git`'s CI take quite a long time: well over an hour. Finally I have a fix for that. All those build minutes were quite wastefully spent on... _sleeping_. The whole story is written down in the commit message, if anyone is interested.
2 parents bd63763 + f27f40f commit 6523961

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

gvfs-helper.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2913,6 +2913,19 @@ static void do_req(const char *url_base,
29132913
curl_easy_setopt(slot->curl, CURLOPT_NOBODY, 0); /* not a HEAD request */
29142914
curl_easy_setopt(slot->curl, CURLOPT_URL, rest_url.buf);
29152915
curl_easy_setopt(slot->curl, CURLOPT_HTTPHEADER, params->headers);
2916+
if (curl_version_info(CURLVERSION_NOW)->version_num < 0x074b00)
2917+
/*
2918+
* cURL 7.75.0 allows headers to be parsed even when
2919+
* `CURLOPT_FAILONERROR` is enabled and the HTTP result code
2920+
* indicates an error. This is the behavior expected by
2921+
* `gvfs-helper`.
2922+
*
2923+
* On older cURL versions, `gvfs-helper` still needs to parse
2924+
* the HTTP headers and therefore needs to _not_ fail upon
2925+
* HTTP result codes indicating errors; For newer cURL
2926+
* versions, we still prefer to enable `FAILONERROR`.
2927+
*/
2928+
curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, (long)0);
29162929

29172930
if (params->b_is_post) {
29182931
curl_easy_setopt(slot->curl, CURLOPT_POST, 1);

t/t5799-gvfs-helper.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,13 @@ test_expect_success 'http-error: 503 Service Unavailable (with retry and no-fall
11221122
#
11231123
#################################################################
11241124

1125+
test_lazy_prereq CURL_7_75_OR_NEWER '
1126+
case "$(curl version | sed -n "1s/^curl \([^ ]*\).*/\1/p")" in
1127+
""|[0-6].*|7.[0-9]*.*|7.[1-6][0-9].*|7.7[0-4]*.*) return 1;;
1128+
*) return 0;;
1129+
esac
1130+
'
1131+
11251132
test_expect_success 'HTTP GET Auth on Origin Server' '
11261133
test_when_finished "per_test_cleanup" &&
11271134
start_gvfs_protocol_server_with_mayhem http_401 &&
@@ -1148,7 +1155,10 @@ test_expect_success 'HTTP GET Auth on Origin Server' '
11481155
test_cmp "$OID_ONE_BLOB_FILE" OUT.actual &&
11491156
11501157
verify_objects_in_shared_cache "$OID_ONE_BLOB_FILE" &&
1151-
verify_connection_count 2
1158+
if test_have_prereq CURL_7_75_OR_NEWER
1159+
then
1160+
verify_connection_count 2
1161+
fi
11521162
'
11531163

11541164
test_expect_success 'HTTP POST Auth on Origin Server' '

0 commit comments

Comments
 (0)