From 74e032e9248e04de7faf0e1ed97f2eb2b34c1251 Mon Sep 17 00:00:00 2001 From: dongjiuzhu1 Date: Mon, 30 Jan 2023 21:53:07 +0800 Subject: [PATCH] drivers/pipes: fix write busy loop because POLLOUT always ready. the size of pipes buffer +1 as compensate the full indicator Signed-off-by: dongjiuzhu1 --- drivers/pipes/pipe_common.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pipes/pipe_common.c b/drivers/pipes/pipe_common.c index dbc90d2ff2..a15504dd8a 100644 --- a/drivers/pipes/pipe_common.c +++ b/drivers/pipes/pipe_common.c @@ -441,7 +441,7 @@ ssize_t pipecommon_read(FAR struct file *filep, FAR char *buffer, size_t len) * FIFO when buffer can accept more than d_polloutthrd bytes. */ - if (pipecommon_bufferused(dev) < (dev->d_bufsize - dev->d_polloutthrd)) + if (pipecommon_bufferused(dev) < (dev->d_bufsize - 1 - dev->d_polloutthrd)) { poll_notify(dev->d_fds, CONFIG_DEV_PIPE_NPOLLWAITERS, POLLOUT); } @@ -699,7 +699,7 @@ int pipecommon_poll(FAR struct file *filep, FAR struct pollfd *fds, eventset = 0; if ((filep->f_oflags & O_WROK) && - nbytes < (dev->d_bufsize - dev->d_polloutthrd)) + nbytes < (dev->d_bufsize - 1 - dev->d_polloutthrd)) { eventset |= POLLOUT; }