This is an automated email from the ASF dual-hosted git repository. xiaoxiang pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
The following commit(s) were added to refs/heads/master by this push: new 65bb956 pipe: check for writers first in case of pipe empty 65bb956 is described below commit 65bb956e5eb921bbe7b1c4beed18979d7c725703 Author: spiriou <simon.pir...@korys.io> AuthorDate: Mon Sep 21 11:41:20 2020 +0200 pipe: check for writers first in case of pipe empty --- drivers/pipes/pipe_common.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/pipes/pipe_common.c b/drivers/pipes/pipe_common.c index e21f169..0bf6095 100644 --- a/drivers/pipes/pipe_common.c +++ b/drivers/pipes/pipe_common.c @@ -426,20 +426,20 @@ ssize_t pipecommon_read(FAR struct file *filep, FAR char *buffer, size_t len) while (dev->d_wrndx == dev->d_rdndx) { - /* If O_NONBLOCK was set, then return EGAIN */ + /* If there are no writers on the pipe, then return end of file */ - if (filep->f_oflags & O_NONBLOCK) + if (dev->d_nwriters <= 0) { nxsem_post(&dev->d_bfsem); - return -EAGAIN; + return 0; } - /* If there are no writers on the pipe, then return end of file */ + /* If O_NONBLOCK was set, then return EGAIN */ - if (dev->d_nwriters <= 0) + if (filep->f_oflags & O_NONBLOCK) { nxsem_post(&dev->d_bfsem); - return 0; + return -EAGAIN; } /* Otherwise, wait for something to be written to the pipe */