X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/29925560efccf3f5801a122f6061e2cf2046c955..3c8cda8b05d6eeaef76c7ccc673fe378b0c74f37:/methods/http.cc diff --git a/methods/http.cc b/methods/http.cc index 068d26978..b3c791fa0 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -368,8 +368,8 @@ bool ServerState::Close() /*}}}*/ // ServerState::RunHeaders - Get the headers before the data /*{{{*/ // --------------------------------------------------------------------- -/* Returns 0 if things are OK, 1 if an IO error occursed and 2 if a header - parse error occured */ +/* Returns 0 if things are OK, 1 if an IO error occurred and 2 if a header + parse error occurred */ int ServerState::RunHeaders() { State = Header; @@ -941,7 +941,8 @@ int HttpMethod::DealWithHeaders(FetchResult &Res,ServerState *Srv) if (Srv->StartPos >= 0) { Res.ResumePoint = Srv->StartPos; - ftruncate(File->Fd(),Srv->StartPos); + if (ftruncate(File->Fd(),Srv->StartPos) < 0) + _error->Errno("ftruncate", _("Failed to truncate file")); } // Set the start point @@ -1164,25 +1165,24 @@ int HttpMethod::Loop() URIDone(Res); } else - { - if (Server->ServerFd == -1) + { + if (Server->ServerFd == -1) + { + FailCounter++; + _error->Discard(); + Server->Close(); + + if (FailCounter >= 2) { - FailCounter++; - _error->Discard(); - Server->Close(); - - if (FailCounter >= 2) - { - Fail(_("Connection failed"),true); - FailCounter = 0; - } - - QueueBack = Queue; + Fail(_("Connection failed"),true); + FailCounter = 0; } - else - Fail(true); - } - + + QueueBack = Queue; + } + else + Fail(true); + } break; }