Skip to content

Commit c04fe8e

Browse files
axboebrauner
authored andcommitted
pipe: check for IOCB_NOWAIT alongside O_NONBLOCK
Pipe reads or writes need to enable nonblocking attempts, if either O_NONBLOCK is set on the file, or IOCB_NOWAIT is set in the iocb being passed in. The latter isn't currently true, ensure we check for both before waiting on data or space. Fixes: afed627 ("pipe: set FMODE_NOWAIT on pipes") Signed-off-by: Jens Axboe <axboe@kernel.dk> Message-Id: <e5946d67-4e5e-b056-ba80-656bab12d9f6@kernel.dk> Signed-off-by: Christian Brauner <brauner@kernel.org>
1 parent ac9a786 commit c04fe8e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/pipe.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,8 @@ pipe_read(struct kiocb *iocb, struct iov_iter *to)
342342
break;
343343
if (ret)
344344
break;
345-
if (filp->f_flags & O_NONBLOCK) {
345+
if ((filp->f_flags & O_NONBLOCK) ||
346+
(iocb->ki_flags & IOCB_NOWAIT)) {
346347
ret = -EAGAIN;
347348
break;
348349
}
@@ -547,7 +548,8 @@ pipe_write(struct kiocb *iocb, struct iov_iter *from)
547548
continue;
548549

549550
/* Wait for buffer space to become available. */
550-
if (filp->f_flags & O_NONBLOCK) {
551+
if ((filp->f_flags & O_NONBLOCK) ||
552+
(iocb->ki_flags & IOCB_NOWAIT)) {
551553
if (!ret)
552554
ret = -EAGAIN;
553555
break;

0 commit comments

Comments
 (0)