diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-01-10 15:24:25 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-01-10 15:24:25 -0800 |
commit | d984592043aec3c9f5b1955560a133896ca115b5 (patch) | |
tree | 7bae1e3caccc682524e72de81e760fc3b031dbef /remote-curl.c | |
parent | 979b82f19f3c44d34779c46c636aade514a711a9 (diff) | |
parent | f8edeaa05d8623a9f6dad408237496c51101aad8 (diff) | |
download | git-d984592043aec3c9f5b1955560a133896ca115b5.tar.gz |
Merge branch 'dt/smart-http-detect-server-going-away'
When the http server gives an incomplete response to a smart-http
rpc call, it could lead to client waiting for a full response that
will never come. Teach the client side to notice this condition
and abort the transfer.
An improvement counterproposal has failed.
cf. <20161114194049.mktpsvgdhex2f4zv@sigill.intra.peff.net>
* dt/smart-http-detect-server-going-away:
upload-pack: optionally allow fetching any sha1
remote-curl: don't hang when a server dies before any output
Diffstat (limited to 'remote-curl.c')
-rw-r--r-- | remote-curl.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/remote-curl.c b/remote-curl.c index 28d9d10638..34a97e7328 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -404,6 +404,7 @@ struct rpc_state { size_t pos; int in; int out; + int any_written; struct strbuf result; unsigned gzip_request : 1; unsigned initial_buffer : 1; @@ -460,6 +461,8 @@ static size_t rpc_in(char *ptr, size_t eltsize, { size_t size = eltsize * nmemb; struct rpc_state *rpc = buffer_; + if (size) + rpc->any_written = 1; write_or_die(rpc->in, ptr, size); return size; } @@ -663,6 +666,8 @@ retry: curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, rpc_in); curl_easy_setopt(slot->curl, CURLOPT_FILE, rpc); + + rpc->any_written = 0; err = run_slot(slot, NULL); if (err == HTTP_REAUTH && !large_request) { credential_fill(&http_auth); @@ -671,6 +676,9 @@ retry: if (err != HTTP_OK) err = -1; + if (!rpc->any_written) + err = -1; + curl_slist_free_all(headers); free(gzip_body); return err; |