From 95ec0a9ce1d830d0003820ed1627f95af92d5aad Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Mon, 15 Feb 2010 09:32:27 -0800 Subject: [PATCH] kernel - Fix issue w/ buffer ortation when doing non-blocking read from bpf * Non-blocking reads from a BPF device not in immediate mode would not rotate the buffers even if the was data in the store buffer, but not in the hold buffer. So until the store buffer fills up, the reads would return -1 and set errno to EWOULDBLOCK. Submitted-by: Guy Harris Taken-from: FreeBSD --- sys/net/bpf.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sys/net/bpf.c b/sys/net/bpf.c index a92c207b67..fc762d6467 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -421,9 +421,13 @@ bpfread(struct dev_read_args *ap) * have arrived to fill the store buffer. */ while (d->bd_hbuf == NULL) { - if ((d->bd_immediate || timed_out) && d->bd_slen != 0) { + if ((d->bd_immediate || (ap->a_ioflag & IO_NDELAY) || timed_out) + && d->bd_slen != 0) { /* - * A packet(s) either arrived since the previous + * A packet(s) either arrived since the previous, + * We're in immediate mode, or are reading + * in non-blocking mode, and a packet(s) + * either arrived since the previous * read or arrived while we were asleep. * Rotate the buffers and return what's here. */ -- 2.11.4.GIT