Date: Sat, 15 Dec 2001 15:10:25 -0600 From: Alfred Perlstein <alfred@FreeBSD.org> To: Bruce Evans <bde@zeta.org.au> Cc: wollman@freebsd.org, net@freebsd.org, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: fifo fix (Re: cvs commit: src/sys/fs/fifofs fifo_vnops.c) Message-ID: <20011215151025.A82439@elvis.mu.org> In-Reply-To: <20011213120830.E79896@elvis.mu.org>; from alfred@FreeBSD.org on Thu, Dec 13, 2001 at 12:08:30PM -0600 References: <20011212125324.R92148@elvis.mu.org> <20011213224148.M469-100000@gamplex.bde.org> <20011213120830.E79896@elvis.mu.org>
next in thread | previous in thread | raw e-mail | index | archive | help
* Alfred Perlstein <alfred@FreeBSD.org> [011213 12:08] wrote: > * Bruce Evans <bde@zeta.org.au> [011213 05:56] wrote: > > > > >From POSIX.1-200x-draft7 (this has not changed since at least the 1990 > > version): > > > > ! 36609 When attempting to read from an empty pipe or FIFO: > > ! > > ! 36610 * If no process has the pipe open for writing, read( ) shall return 0 to indicate end-of-file. > > > > The changes make read() block instead, at least for the non-O_NONBLOCK case. > > I'm not sure of the effect of the change in the O_NONBLOCK case, but it > > seems likely that -1/EAGAIN is returned instead of 0/no-error. > > Ok, I can fix this. (I hope :) ) Can people take a look at this fix? It seems to dtrt, but I need feedback here. It basically backs out my last two revisions and changes the hacks the poll call to seemingly do the right thing. Index: fifo_vnops.c =================================================================== RCS file: /home/ncvs/src/sys/fs/fifofs/fifo_vnops.c,v retrieving revision 1.57 diff -u -r1.57 fifo_vnops.c --- fifo_vnops.c 12 Dec 2001 09:35:33 -0000 1.57 +++ fifo_vnops.c 15 Dec 2001 21:25:30 -0000 @@ -199,6 +199,7 @@ } fip->fi_readers = fip->fi_writers = 0; wso->so_snd.sb_lowat = PIPE_BUF; + rso->so_state |= SS_CANTRCVMORE; } if (ap->a_mode & FREAD) { fip->fi_readers++; @@ -283,11 +284,6 @@ VOP_UNLOCK(ap->a_vp, 0, td); error = soreceive(rso, (struct sockaddr **)0, uio, (struct mbuf **)0, (struct mbuf **)0, (int *)0); - /* - * Clear EOF indication after first such return. - */ - if (uio->uio_resid == startresid) - rso->so_state &= ~SS_CANTRCVMORE; vn_lock(ap->a_vp, LK_EXCLUSIVE | LK_RETRY, td); if (ap->a_ioflag & IO_NDELAY) rso->so_state &= ~SS_NBIO; @@ -455,13 +451,23 @@ } */ *ap; { struct file filetmp; - int revents = 0; + int s, revents = 0; if (ap->a_events & (POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND)) { + struct socket *so; + int oflg; + filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_readsock; + so = (struct socket *)filetmp.f_data; + s = splnet(); + oflg = so->so_state & SS_CANTRCVMORE; + if (ap->a_vp->v_fifoinfo->fi_writers == 0) + so->so_state &= ~SS_CANTRCVMORE; if (filetmp.f_data) revents |= soo_poll(&filetmp, ap->a_events, ap->a_cred, ap->a_td); + so->so_state |= oflg; + splx(s); } if (ap->a_events & (POLLOUT | POLLWRNORM | POLLWRBAND)) { filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_writesock; To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20011215151025.A82439>