From ad06298ab83d37881157c0ab20c1a063318b03e9 Mon Sep 17 00:00:00 2001 From: Matheus Date: Sun, 23 Jun 2024 18:13:16 -0300 Subject: [PATCH] pipefs: make poll better --- kernel-src/fs/pipefs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel-src/fs/pipefs.c b/kernel-src/fs/pipefs.c index 0c6d4166..28c29d25 100644 --- a/kernel-src/fs/pipefs.c +++ b/kernel-src/fs/pipefs.c @@ -73,7 +73,9 @@ static int internalpoll(vnode_t *node, polldata_t *data, int events) { events |= POLLERR; if (pipenode->readers == 0) revents |= POLLERR; - else if (RINGBUFFER_DATACOUNT(&pipenode->data) < BUFFER_SIZE) + // poll will only return POLLOUT if an atomic write can be done without blocking + // this is undocumented in POSIX but many unices implement it like this + else if (RINGBUFFER_DATACOUNT(&pipenode->data) < BUFFER_SIZE - PIPE_ATOMIC_SIZE) revents |= POLLOUT; }