Skip to content

Commit aad1028

Browse files
committed
squash! gvfs-helper: expose gvfs/objects GET and POST semantics
For the t5799.13(no server) test case, we specifically work around a change of behavior in cURL v8.16.0 where the generous default connection timeout of 5 minutes started to be applied several times in instances where a connection is refused. The work-around is to add the `--connect-timeout-ms` option and set it really low in that test case. Unfortunately, with that work-around that cURL version will report a timeout instead of a failure to connect. See curl/curl#18767 for details. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 5d43533 commit aad1028

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

gvfs-helper.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ static struct gh__global {
381381
int cache_server_is_initialized; /* did sub-command look for one */
382382
int main_creds_need_approval; /* try to only approve them once */
383383

384+
unsigned long connect_timeout_ms;
384385
} gh__global;
385386

386387
enum gh__server_type {
@@ -2970,6 +2971,10 @@ static void do_req(const char *url_base,
29702971
curl_easy_setopt(slot->curl, CURLOPT_NOPROGRESS, 1L);
29712972
}
29722973

2974+
if (gh__global.connect_timeout_ms)
2975+
curl_easy_setopt(slot->curl, CURLOPT_CONNECTTIMEOUT_MS,
2976+
gh__global.connect_timeout_ms);
2977+
29732978
gh__run_one_slot(slot, params, status);
29742979
strbuf_release(&rest_url);
29752980
}
@@ -3678,6 +3683,9 @@ static enum gh__error_code do_sub_cmd__get(int argc, const char **argv)
36783683
static struct option get_options[] = {
36793684
OPT_INTEGER('r', "max-retries", &gh__cmd_opts.max_retries,
36803685
N_("retries for transient network errors")),
3686+
OPT_UNSIGNED(0, "connect-timeout-ms",
3687+
&gh__global.connect_timeout_ms,
3688+
N_("try to connect only for this many milliseconds")),
36813689
OPT_END(),
36823690
};
36833691

t/t5799-gvfs-helper.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -850,6 +850,11 @@ mayhem_observed__close () {
850850
fi
851851
}
852852

853+
test_lazy_prereq CURL_8_16_0 '
854+
git gvfs-helper curl-version = 8.16.0 ||
855+
test 8.15.0-DEV = "$(git gvfs-helper curl-version)"
856+
'
857+
853858
test_expect_success 'curl-error: no server' '
854859
test_when_finished "per_test_cleanup" &&
855860
@@ -864,10 +869,18 @@ test_expect_success 'curl-error: no server' '
864869
--remote=origin \
865870
get \
866871
--max-retries=2 \
872+
--connect-timeout-ms=200 \
867873
<"$OIDS_FILE" >OUT.output 2>OUT.stderr &&
868874
869-
# CURLE_COULDNT_CONNECT 7
870-
test_grep "error: get: (curl:7)" OUT.stderr
875+
if test_have_prereq CURL_8_16_0
876+
then
877+
# CURLE_COULDNT_CONNECT 7
878+
# CURLE_OPERATION_TIMEDOUT 28
879+
test_grep "error: get: (curl:\(7\|28\))" OUT.stderr
880+
else
881+
# CURLE_COULDNT_CONNECT 7
882+
test_grep "error: get: (curl:7)" OUT.stderr
883+
fi
871884
'
872885

873886
test_expect_success 'curl-error: close socket while reading request' '

0 commit comments

Comments
 (0)