1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-18 15:30:21 +00:00

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.
This commit is contained in:
Dag-Erling Smørgrav 2002-10-27 17:20:49 +00:00
parent 7ab4b95b67
commit 1a5424b137
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=106049

View File

@ -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);
}