summaryrefslogtreecommitdiff
path: root/remote-curl.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2017-01-17 15:19:03 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2017-01-17 15:19:03 -0800
commit48d23c12e7329213e0dfd73bbffc6ad05efcaf9d (patch)
tree0be1b42a367d5cd1c4bfb0296695be2c7a157fda /remote-curl.c
parentMerge branch 'mk/mingw-winansi-ttyname-termination-fix' into maint (diff)
parentupload-pack: optionally allow fetching any sha1 (diff)
downloadtgif-48d23c12e7329213e0dfd73bbffc6ad05efcaf9d.tar.xz
Merge branch 'dt/smart-http-detect-server-going-away' into maint
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.c8
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;