summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2019-03-24 20:49:57 -0700
committerEdward Thomson <ethomson@edwardthomson.com>2019-06-10 19:58:22 +0100
commit9af1de5bc5b57a68bd659e9f76540c3f569772e8 (patch)
tree3be09aa7602303d1cd04edbb598796868171f8fb
parent4c2ca1ba4aebb201d777ee9a2d09daf445290e9f (diff)
downloadlibgit2-9af1de5bc5b57a68bd659e9f76540c3f569772e8.tar.gz
http: stop on server EOF
We stop the read loop when we have read all the data. We should also consider the server's feelings. If the server hangs up on us, we need to stop our read loop. Otherwise, we'll try to read from the server - and fail - ad infinitum.
-rw-r--r--src/transports/http.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/transports/http.c b/src/transports/http.c
index 8e0af1beb..d2ae559be 100644
--- a/src/transports/http.c
+++ b/src/transports/http.c
@@ -934,8 +934,13 @@ replay:
while (!bytes_read && !t->parse_finished) {
t->parse_buffer.offset = 0;
- if ((error = gitno_recv(&t->parse_buffer)) < 0)
+ if ((error = gitno_recv(&t->parse_buffer)) < 0) {
goto done;
+ } else if (error == 0) {
+ git_error_set(GIT_ERROR_NET, "unexpected disconnection from server");
+ error = -1;
+ goto done;
+ }
/*
* This call to http_parser_execute will invoke the on_*
@@ -1178,8 +1183,13 @@ replay:
data_offset = t->parse_buffer.offset;
- if ((error = gitno_recv(&t->parse_buffer)) < 0)
+ if ((error = gitno_recv(&t->parse_buffer)) < 0) {
goto done;
+ } else if (error == 0) {
+ git_error_set(GIT_ERROR_NET, "unexpected disconnection from server");
+ error = -1;
+ goto done;
+ }
/*
* This call to http_parser_execute will result in invocations