git: 545db925c3d5 - main - pipe: fix EOF case for non-blocking fds

From: Mateusz Guzik <mjg_at_FreeBSD.org>
Date: Thu, 18 Aug 2022 21:24:30 UTC
The branch main has been updated by mjg:

URL: https://cgit.FreeBSD.org/src/commit/?id=545db925c3d5408e71e21432895770cd49fd2cf3

commit 545db925c3d5408e71e21432895770cd49fd2cf3
Author:     Mateusz Guzik <mjg@FreeBSD.org>
AuthorDate: 2022-08-18 21:23:53 +0000
Commit:     Mateusz Guzik <mjg@FreeBSD.org>
CommitDate: 2022-08-18 21:23:53 +0000

    pipe: fix EOF case for non-blocking fds
    
    In particular unbreaks 'go build'.
---
 sys/kern/sys_pipe.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/sys/kern/sys_pipe.c b/sys/kern/sys_pipe.c
index f9060ba2c8a6..67c340e9d39a 100644
--- a/sys/kern/sys_pipe.c
+++ b/sys/kern/sys_pipe.c
@@ -734,9 +734,8 @@ pipe_read(struct file *fp, struct uio *uio, struct ucred *active_cred,
 	if ((fp->f_flag & FNONBLOCK) != 0 && !mac_pipe_check_read_enabled()) {
 		if (__predict_false(uio->uio_resid == 0))
 			return (0);
-		if ((atomic_load_short(&rpipe->pipe_state) & PIPE_EOF) != 0)
-			return (0);
-		if (atomic_load_int(&rpipe->pipe_buffer.cnt) == 0 &&
+		if ((atomic_load_short(&rpipe->pipe_state) & PIPE_EOF) == 0 &&
+		    atomic_load_int(&rpipe->pipe_buffer.cnt) == 0 &&
 		    atomic_load_int(&rpipe->pipe_pages.cnt) == 0)
 			return (EAGAIN);
 	}