From fba3cfdef21945e2fcc20b90c782c736577520b8 Mon Sep 17 00:00:00 2001 From: John Polstra Date: Sun, 17 Dec 2000 20:50:22 +0000 Subject: [PATCH] Fix bug: a read() on a bpf device which was in non-blocking mode and had no data available returned 0. Now it returns -1 with errno set to EWOULDBLOCK (== EAGAIN) as it should. This fix makes the bpf device usable in threaded programs. Reviewed by: bde --- sys/net/bpf.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/sys/net/bpf.c b/sys/net/bpf.c index d2eaa39dffe..12e375e37e9 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -500,11 +500,12 @@ bpfread(dev, uio, ioflag) return (ENXIO); } - if (ioflag & IO_NDELAY) - error = EWOULDBLOCK; - else - error = BPF_SLEEP((caddr_t)d, PRINET|PCATCH, "bpf", - d->bd_rtout); + if (ioflag & IO_NDELAY) { + splx(s); + return (EWOULDBLOCK); + } + error = BPF_SLEEP((caddr_t)d, PRINET|PCATCH, "bpf", + d->bd_rtout); if (error == EINTR || error == ERESTART) { splx(s); return (error);