From owner-freebsd-net Mon Dec 17 5:10:29 2001 Delivered-To: freebsd-net@freebsd.org Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by hub.freebsd.org (Postfix) with ESMTP id 8891D37B41D; Mon, 17 Dec 2001 05:10:09 -0800 (PST) Received: from bde.zeta.org.au (bde.zeta.org.au [203.2.228.102]) by mailman.zeta.org.au (8.9.3/8.8.7) with ESMTP id AAA31518; Tue, 18 Dec 2001 00:10:04 +1100 Date: Tue, 18 Dec 2001 00:09:42 +1100 (EST) From: Bruce Evans X-X-Sender: To: Alfred Perlstein Cc: , , , Subject: Re: fifo fix (Re: cvs commit: src/sys/fs/fifofs fifo_vnops.c) In-Reply-To: <20011215151025.A82439@elvis.mu.org> Message-ID: <20011217230720.N13599-100000@gamplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-net@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org On Sat, 15 Dec 2001, Alfred Perlstein wrote: > 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 > ... > @@ -455,13 +451,23 @@ > } */ *ap; > { > struct file filetmp; > - int revents = 0; > + int s, revents = 0; New style bug: disordered declaration. (Old style bug: initialized in auto declaration.) > > if (ap->a_events & (POLLIN | POLLPRI | POLLRDNORM | POLLRDBAND)) { > + struct socket *so; > + int oflg; Style bugs: nested declarations. > + > 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); I'm not happy with frobbing the socket state. I suggest frobbing the events mask instead. Either use a flag to tell sopoll() to ignore SS_CANTRCVMORE, or use new events POLLIN_IGNORE_EOF and POLLRDNORM_IGNORE_EOF (convert the userland POLLIN/POLLRDNORM to these and change sopoll() to support them). > } > if (ap->a_events & (POLLOUT | POLLWRNORM | POLLWRBAND)) { > filetmp.f_data = (caddr_t)ap->a_vp->v_fifoinfo->fi_writesock; > Similar changes may be needed for kevent(). kevent() has a way to modify modify the usual watermark handling for reads, but doesn't have anything similar for EOFs, although it already has more complete EOF handling (filt_kqread() sets EV_EOF for EOFs, but sopoll() is missing support for POLLHUP). Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-net" in the body of the message