Skip to content

Commit 6c3d2e7

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 232fa9a commit 6c3d2e7

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

gvfs-helper.c

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

378+
unsigned long connect_timeout_ms;
378379
} gh__global;
379380

380381
enum gh__server_type {
@@ -2964,6 +2965,10 @@ static void do_req(const char *url_base,
29642965
curl_easy_setopt(slot->curl, CURLOPT_NOPROGRESS, 1L);
29652966
}
29662967

2968+
if (gh__global.connect_timeout_ms)
2969+
curl_easy_setopt(slot->curl, CURLOPT_CONNECTTIMEOUT_MS,
2970+
gh__global.connect_timeout_ms);
2971+
29672972
gh__run_one_slot(slot, params, status);
29682973
strbuf_release(&rest_url);
29692974
}
@@ -3672,6 +3677,9 @@ static enum gh__error_code do_sub_cmd__get(int argc, const char **argv)
36723677
static struct option get_options[] = {
36733678
OPT_INTEGER('r', "max-retries", &gh__cmd_opts.max_retries,
36743679
N_("retries for transient network errors")),
3680+
OPT_UNSIGNED(0, "connect-timeout-ms",
3681+
&gh__global.connect_timeout_ms,
3682+
N_("try to connect only for this many milliseconds")),
36753683
OPT_END(),
36763684
};
36773685

t/t5799-gvfs-helper.sh

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

853+
test_lazy_prereq CURL_8_16_0 '
854+
case "$(curl --version | sed -n "1s/^curl \([^ ]*\).*/\1/p")" in
855+
8.16.0) return 0;;
856+
*) return 1;;
857+
esac
858+
'
859+
853860
test_expect_success 'curl-error: no server' '
854861
test_when_finished "per_test_cleanup" &&
855862
@@ -864,10 +871,18 @@ test_expect_success 'curl-error: no server' '
864871
--remote=origin \
865872
get \
866873
--max-retries=2 \
874+
--connect-timeout-ms=200 \
867875
<"$OIDS_FILE" >OUT.output 2>OUT.stderr &&
868876
869-
# CURLE_COULDNT_CONNECT 7
870-
test_grep "error: get: (curl:7)" OUT.stderr
877+
if test_have_prereq CURL_8_16_0
878+
then
879+
# CURLE_COULDNT_CONNECT 7
880+
# CURLE_OPERATION_TIMEDOUT 28
881+
test_grep "error: get: (curl:\(7\|28\))" OUT.stderr
882+
else
883+
# CURLE_COULDNT_CONNECT 7
884+
test_grep "error: get: (curl:7)" OUT.stderr
885+
fi
871886
'
872887

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

0 commit comments

Comments
 (0)