Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 18 Dec 2001 00:09:42 +1100 (EST)
From:      Bruce Evans <bde@zeta.org.au>
To:        Alfred Perlstein <alfred@FreeBSD.org>
Cc:        <wollman@FreeBSD.org>, <net@FreeBSD.org>, <cvs-committers@FreeBSD.org>, <cvs-all@FreeBSD.org>
Subject:   Re: fifo fix (Re: cvs commit: src/sys/fs/fifofs fifo_vnops.c)
Message-ID:  <20011217230720.N13599-100000@gamplex.bde.org>
In-Reply-To: <20011215151025.A82439@elvis.mu.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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 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?20011217230720.N13599-100000>