Branch: Tag:

2017-04-24

2017-04-24 09:57:21 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Stdio: Fixed error handling in do_read() some more.

Read data should not be thrown away due to a later error...

Potential fix for Process.popen() returning zero in some circumstances.

757:       /* make space for exactly len bytes plus the terminating null byte */    if (UNLIKELY(!buffer_ensure_space_nothrow(&buf, len+1))) { -  buffer_free(&buf); +     e = ENOMEM;    break;    }
768:       THREADS_DISALLOW();    -  check_threads_etc(); -  +     if (LIKELY(i >= 0)) {    if ((size_t)i < len) buffer_remove(&buf, len - i);    bytes -= i;    if (!i || !all) break;    } else {    e=errno; -  +  buffer_remove(&buf, len); +  +  check_threads_etc(); +     if (e == EINTR) {    e = 0; -  buffer_remove(&buf, len); +     continue;    }    -  buffer_free(&buf); +     break;    }    }       -  if (e) { +  if (e && !buffer_content_length(&buf)) { +  buffer_free(&buf);    *err = e;    return NULL;    }