From cb743d117bcc666dab4c5948b1227ed2edbd0578 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 29 Jun 2020 11:45:45 +0200 Subject: http: Only return false for EOF if we actually did not read anything This should avoid the need to Flush the buffer in Die(), because if we read anything, we are returning true, and not entering Die() at that point. Also Write() does not have a concept of EOF, so get rid of code handling that there. Was that copied from Read()? --- methods/http.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'methods') diff --git a/methods/http.cc b/methods/http.cc index fef719e74..83f1bde8d 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -94,6 +94,7 @@ void CircleBuf::Reset() is non-blocking.. */ bool CircleBuf::Read(std::unique_ptr const &Fd) { + size_t ReadThisCycle = 0; while (1) { // Woops, buffer is full @@ -131,7 +132,7 @@ bool CircleBuf::Read(std::unique_ptr const &Fd) CircleBuf::BwTickReadData += Res; if (Res == 0) - return false; + return ReadThisCycle != 0; if (Res < 0) { if (errno == EAGAIN) @@ -140,6 +141,7 @@ bool CircleBuf::Read(std::unique_ptr const &Fd) } InP += Res; + ReadThisCycle += Res; } } /*}}}*/ @@ -204,8 +206,6 @@ bool CircleBuf::Write(std::unique_ptr const &Fd) ssize_t Res; Res = Fd->Write(Buf + (OutP % Size), LeftWrite()); - if (Res == 0) - return false; if (Res < 0) { if (errno == EAGAIN) @@ -215,7 +215,7 @@ bool CircleBuf::Write(std::unique_ptr const &Fd) } TotalWriten += Res; - + if (Hash != NULL) Hash->Add(Buf + (OutP%Size),Res); -- cgit v1.2.3