io: Return from read even if return == -1 and errno == 0

This happens on OpenIndiana/Solaris/Illumos/SunOS.

Elsewhere we use read_blocked, which already returned in this
case (and which we might want to use here as well!).
This commit is contained in:
Fabian Homborg 2019-02-13 20:15:09 +01:00
parent 4132bb1a19
commit c0dc1870f0

View File

@ -95,12 +95,17 @@ void io_buffer_t::run_background_fillthread(autoclose_fd_t readfd) {
scoped_lock locker(append_lock_);
ssize_t ret;
do {
errno = 0;
char buff[4096];
ret = read(fd, buff, sizeof buff);
if (ret > 0) {
buffer_.append(&buff[0], &buff[ret]);
} else if (ret == 0) {
shutdown = true;
} else if (ret == -1 && errno == 0) {
// No specific error. We assume we just return,
// since that's what we do in read_blocked.
return;
} else if (errno != EINTR && errno != EAGAIN) {
wperror(L"read");
return;