summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/libfetch/common.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/libfetch/common.c b/lib/libfetch/common.c
index ab3f4ca..1ae9193 100644
--- a/lib/libfetch/common.c
+++ b/lib/libfetch/common.c
@@ -384,12 +384,8 @@ _fetch_read(conn_t *conn, char *buf, size_t len)
else
#endif
rlen = read(conn->sd, buf, len);
- if (rlen == 0) {
- /* we consider a short read a failure */
- errno = EPIPE;
- _fetch_syserr();
- return (-1);
- }
+ if (rlen == 0)
+ break;
if (rlen < 0) {
if (errno == EINTR && fetchRestartCalls)
continue;
@@ -399,6 +395,12 @@ _fetch_read(conn_t *conn, char *buf, size_t len)
buf += rlen;
total += rlen;
}
+ if (total == 0 && len != 0) {
+ /* no data available at all */
+ errno = EPIPE;
+ _fetch_syserr();
+ return (-1);
+ }
return (total);
}
OpenPOWER on IntegriCloud