Fix broken read_ni() not making fd non-blocking on Linux

The incorrect order of operations was being used since && binds tighter than ||
in rust (as with most sane languages).

Under Linux, EAGAIN == EWOULDBLOCK so this would always succeed in the case of a
non-blocking fd without making the call to make_fd_nonblocking().

Comparing to the 3.7.0 C++ code, it looks like this was an oversight introduced
in the migration to rust.
This commit is contained in:
Mahmoud Al-Qudsi 2024-03-26 01:03:07 -05:00
parent 62a49acda3
commit 326d986186

View file

@ -709,8 +709,8 @@ fn read_ni(parser: &Parser, fd: RawFd, io: &IoChain) -> i32 {
Err(err) => {
if err == nix::Error::EINTR {
continue;
} else if err == nix::Error::EAGAIN
|| err == nix::Error::EWOULDBLOCK && make_fd_blocking(fd).is_ok()
} else if (err == nix::Error::EAGAIN || err == nix::Error::EWOULDBLOCK)
&& make_fd_blocking(fd).is_ok()
{
// We succeeded in making the fd blocking, keep going.
continue;