> I believe you're misunderstanding the meaning of the timeout in select(2).
> Timeout applies only when no FDs are ready.

The specific problem with bpf is that one might have a half-full buffer
of captured data when the select timeout hits. In that case the select
returns with no FDs ready while I think it really should return with
the bpf fd. (and if you look at the code on sys/net/bpf.c, there is
timeout handling towards that goal) but I´ve yet to figure out where it goes
wrong.

IMO, at timeout the code should check if bd_slen > 0 and if yes,
do ROTATE_BUFFERS and bpf_wakeup()

Unfortunately I´m not a kernel wizard enough to have fixed this, at least
not yet.

The functionality I´m looking for is to get all the packets accumulated, say
in 1 second in single read regardless of if I got a buffer´s full of data.

>
> Also, you might be better off setting immediate mode on your bpf fd,
> if you want a return before the buffer is full.
>
Immediate mode practically causes the reader to be waken up for every packet,
ending up with huge number of small reads which is highly ineffective.

Pete


> On Mon, Nov 04, 2002 at 12:12:26AM +0200, Petri Helenius wrote:
> >
> > I believe the select operation on bpf is not functioning as supposed to.
> > I?m calling select with 100ms timeout. The bpf interface is listening to
> > an interface with constant packet rate, so it?s certain that multiple
packets
> > have been received during the select call. However the fd for the bpf
> > device is not set until the bpf buffer is full. (which might be several
seconds
> > away since I?m using fairly large bpf buffers)
> >
> > Looking at the code I get the impression that if there are packets on the
bpf
> > buffer when the select timeouts, it should return the fd for the bpf ?
> >
> > Pete
> >
> >
> >
> > To Unsubscribe: send mail to [EMAIL PROTECTED]
> > with "unsubscribe freebsd-net" in the body of the message
>
> --
> Barney Wolff         http://www.databus.com/bwresume.pdf
> I'm available by contract or FT, in the NYC metro area or via the 'Net.
>


To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-net" in the body of the message

Reply via email to