Skip to content

Commit b79ae3c

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 <johannes.schindelin@gmx.de>
1 parent 5d43533 commit b79ae3c

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
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: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -850,9 +850,25 @@ 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
861+
connect_timeout_ms= &&
862+
# CURLE_COULDNT_CONNECT 7
863+
regex="error: get: (curl:7)" &&
864+
if test_have_prereq CURL_8_16_0
865+
then
866+
connect_timeout_ms=--connect-timeout-ms=200 &&
867+
# CURLE_COULDNT_CONNECT 7
868+
# CURLE_OPERATION_TIMEDOUT 28
869+
regex="error: get: (curl:\(7\|28\))"
870+
fi &&
871+
856872
# Try to do a multi-get without a server.
857873
#
858874
# Use small max-retry value because of exponential backoff,
@@ -864,10 +880,9 @@ test_expect_success 'curl-error: no server' '
864880
--remote=origin \
865881
get \
866882
--max-retries=2 \
883+
$connect_timeout_ms \
867884
<"$OIDS_FILE" >OUT.output 2>OUT.stderr &&
868-
869-
# CURLE_COULDNT_CONNECT 7
870-
test_grep "error: get: (curl:7)" OUT.stderr
885+
test_grep "$regex" OUT.stderr
871886
'
872887

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

0 commit comments

Comments
 (0)