From 37b3ac0423b87b7d831812bc3faecdeb2d29201f Mon Sep 17 00:00:00 2001 From: des Date: Sun, 27 Oct 2002 17:20:49 +0000 Subject: Slight amendment to rev 1.34: instead of considering any short read an error, only report an error if no data was read at all (unless len was 0 to start with). Otherwise, the final read of practically any transfer will end in a fatal error. --- lib/libfetch/common.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'lib/libfetch/common.c') 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); } -- cgit v1.1