Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 23 Mar 2002 17:50:03 -0800 (PST)
From:      Lev Walkin <vlm@netli.com>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: kern/36219: poll() behaves erratic on BPF file descriptors.
Message-ID:  <200203240150.g2O1o3j46675@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR kern/36219; it has been noted by GNATS.

From: Lev Walkin <vlm@netli.com>
To: Garance A Drosehn <gad@FreeBSD.org>
Cc: freebsd-gnats-submit@FreeBSD.org
Subject: Re: kern/36219: poll() behaves erratic on BPF file descriptors.
Date: Sat, 23 Mar 2002 17:45:38 -0800

 Garance A Drosehn wrote:
 > I have applied the first part of this patch which changes the
 > POLLIN to POLLOUT on freebsd-stable.  The POLLIN was a mistake
 > in one of my earlier commits.
 
 Yeah, sure.
 
 > I do not know about the rest of the proposed patch.
 
 Well, let's explain things.
 
 What did we had:
 
 if (d->bd_hlen != 0 || ((d->bd_immediate || d->bd_state == 
 BPF_TIMED_OUT) && d->bd_slen != 0)
 
 Suppose that we have no data in hold buffer and no data in
 store buffer. We also have a timeout state (bd_state = BPF_TIMED_OUT).
 
 So, expression transfers to
 
 if( 0 != 0 || (0 || 2 == 2) && 0 != 0)
 
 or
 
 if(0 || 1 && 0)
 
 or
 
 if(0).
 
 But we do want to report this timeout up to the application!
 So, we will not succeed in that.
 
 What do we need, is to report back POLLIN event in these
 cases:
 1. Hold buffer is not empty.
 2. We were requested to answer immediately if we have any amount of
 data.
 3. We've experienced a time out.
 
 This is effectively means the following
 
 +               if (d->bd_hlen != 0
 +                       || (d->bd_immediate && d->bd_slen != 0)
 +                       || d->bd_state == BPF_TIMED_OUT
 +               ) {
 
 
 In the FreeBSD 4.4 code we had these lines:
 
 if (d->bd_hlen != 0 || (d->bd_immediate && d->bd_slen != 0))
 
 So it seems somebody installed a "d->bd_state == BPF_TIMED_OUT"
 in the wrong place.
 
 
 Please, consider applying the rest of the patch.
 
 
 -- 
 Lev Walkin
 vlm@netli.com
 

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




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