From owner-freebsd-bugs Sat Mar 23 17:50:14 2002 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 47C0037B419 for ; Sat, 23 Mar 2002 17:50:03 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.6/8.11.6) id g2O1o3j46675; Sat, 23 Mar 2002 17:50:03 -0800 (PST) (envelope-from gnats) Date: Sat, 23 Mar 2002 17:50:03 -0800 (PST) Message-Id: <200203240150.g2O1o3j46675@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org Cc: From: Lev Walkin Subject: Re: kern/36219: poll() behaves erratic on BPF file descriptors. Reply-To: Lev Walkin Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org The following reply was made to PR kern/36219; it has been noted by GNATS. From: Lev Walkin To: Garance A Drosehn 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