aboutsummaryrefslogtreecommitdiff
path: root/sys/net/bpf.c
diff options
context:
space:
mode:
authorJohn Polstra <jdp@FreeBSD.org>2000-12-17 20:50:22 +0000
committerJohn Polstra <jdp@FreeBSD.org>2000-12-17 20:50:22 +0000
commitfba3cfdef21945e2fcc20b90c782c736577520b8 (patch)
tree7db9c5c5e7c2b2b66c4e68a5d3e94c9162ea007c /sys/net/bpf.c
parent61ffadb1852dfaa3d62c7d192b23939b22687bfb (diff)
downloadsrc-fba3cfdef21945e2fcc20b90c782c736577520b8.tar.gz
src-fba3cfdef21945e2fcc20b90c782c736577520b8.zip
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
Notes
Notes: svn path=/head/; revision=70127
Diffstat (limited to 'sys/net/bpf.c')
-rw-r--r--sys/net/bpf.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index d2eaa39dffe1..12e375e37e9b 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);