summaryrefslogtreecommitdiff
path: root/methods
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2020-06-29 11:45:45 +0200
committerJulian Andres Klode <julian.klode@canonical.com>2020-07-24 16:30:43 +0200
commitcb743d117bcc666dab4c5948b1227ed2edbd0578 (patch)
tree4e8866f0c07304edd39da483b53dd13b8b870ee7 /methods
parent1ee3b64be054a8deb6a598d93047637448e1928e (diff)
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()?
Diffstat (limited to 'methods')
-rw-r--r--methods/http.cc8
1 files changed, 4 insertions, 4 deletions
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<MethodFd> const &Fd)
{
+ size_t ReadThisCycle = 0;
while (1)
{
// Woops, buffer is full
@@ -131,7 +132,7 @@ bool CircleBuf::Read(std::unique_ptr<MethodFd> 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<MethodFd> const &Fd)
}
InP += Res;
+ ReadThisCycle += Res;
}
}
/*}}}*/
@@ -204,8 +206,6 @@ bool CircleBuf::Write(std::unique_ptr<MethodFd> 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<MethodFd> const &Fd)
}
TotalWriten += Res;
-
+
if (Hash != NULL)
Hash->Add(Buf + (OutP%Size),Res);