Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 10 Nov 2001 17:14:26 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Bill Fenner <fenner@research.att.com>
Cc:        <alfred@freebsd.org>, <cvs-committers@freebsd.org>, <cvs-all@freebsd.org>
Subject:   Re: cvs commit: src/sys/fs/fifofs fifo_vnops.c
Message-ID:  <20011110165603.B15842-100000@delplex.bde.org>
In-Reply-To: <200111091803.KAA24774@windsor.research.att.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 9 Nov 2001, Bill Fenner wrote:

> POSIX FIFOs seem relatively useless, unless there's always a
> writer present.  Without a writer, a reader has to spin (either
> in select+read or just read) until a writer is present.

They are perfectly useful.  The user just has to supply a dummy writer
if it wants select() to block when there is no data and no writers.
This breaks detection of when there are no writers, but so does clearing
SS_CANTRCVMORE.

For read(), it is normal to have to spin if there is no writer and you
don't want to block.  You have to use non-blocking reads to avoid
blocking.  Recent changes mainly break detection of whether there is
no writer (when read() returns immediately because there is no data).
The correct clearly specified behaviour is:
- return 0 and don't set errno if there is no writer
- return -1 and set errno to EAGAIN if there is a writer
Recent changes break this to always return -1/EAGAIN.

I don't really care about the select() behaviour, but any "fix" for it
must not break read() and must somehow weasel around select() having
surprisingly different semantics.

> I can't tell if POSIX really defined FIFOs to be useless, or we're just
> misinterpreting the standards-speak.  I'd prefer if an "empty FIFO with
> no writers" was really an "empty FIFO with no writers where the EOF
> condition hasn't been delivered yet"; then read() could block (or return
> EAGAIN or EWOULDBLOCK) when there were no writers yet, and could go back
> to that condition after the EOF of all the writers leaving was delivered.

How would it know if the condition was delivered?  Some of the readers that
care about this condition might not have inquired about it yet.

Bruce


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe cvs-all" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011110165603.B15842-100000>