diff options
author | des <des@FreeBSD.org> | 2002-10-27 17:20:49 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2002-10-27 17:20:49 +0000 |
commit | 37b3ac0423b87b7d831812bc3faecdeb2d29201f (patch) | |
tree | 935d7031b71b01a93eb8b3f699d776678316567f /lib/libfetch | |
parent | 4ab3964b05d907545e2182f08323188bbde56ba6 (diff) | |
download | FreeBSD-src-37b3ac0423b87b7d831812bc3faecdeb2d29201f.zip FreeBSD-src-37b3ac0423b87b7d831812bc3faecdeb2d29201f.tar.gz |
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.
Diffstat (limited to 'lib/libfetch')
-rw-r--r-- | lib/libfetch/common.c | 14 |
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); } |