Originally it would return -1 (without setting errno) if the fd was
already at EOF when you called read_all.
This is already fixed in sendfile_all.
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Egor Chelak <egor.chelak@gmail.com>
memset(buf, 0, count);
while (count > 0) {
ret = read(fd, buf, count);
- if (ret <= 0) {
- if (ret < 0 && (errno == EAGAIN || errno == EINTR) && (tries++ < 5)) {
+ if (ret < 0) {
+ if ((errno == EAGAIN || errno == EINTR) && (tries++ < 5)) {
xusleep(250000);
continue;
}
return c ? c : -1;
}
+ if (ret == 0)
+ return c;
tries = 0;
count -= ret;
buf += ret;