From dac5d7fe4f7192805e405fe05a11a60ac30c800e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 3 Aug 2010 19:27:52 +0000 Subject: [PATCH] * Made sure that at least the common case with a single writer exits write() once the file descriptor is closed. * Reinstantiated the FIFO functionality as long there are no writers yet as explained by Ingo. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37883 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/fs/fifo.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/system/kernel/fs/fifo.cpp b/src/system/kernel/fs/fifo.cpp index 99a5009ffc..7f2dafda71 100644 --- a/src/system/kernel/fs/fifo.cpp +++ b/src/system/kernel/fs/fifo.cpp @@ -458,7 +458,7 @@ Inode::ReadDataFromBuffer(void* data, size_t* _length, bool nonBlocking, if (nonBlocking) return B_WOULD_BLOCK; - if (fWriterCount == 0) + if (fActive && fWriterCount == 0) return B_OK; TRACE("Inode %p::%s(): wait for data, request %p\n", this, __FUNCTION__, @@ -653,6 +653,13 @@ Inode::Close(int openMode, file_cookie* cookie) NotifyEndClosed(false); } + if (fWriterCount == 0) { + // Notify any still reading writers to stop + // TODO: This only works reliable if there is only one writer - we could + // do the same thing done for the read requests. + fWriteCondition.NotifyAll(B_FILE_ERROR); + } + if (fReaderCount == 0 && fWriterCount == 0) { fActive = false; fBuffer.DeleteBuffer();