summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortedu <tedu@openbsd.org>2015-01-09 04:59:54 +0000
committertedu <tedu@openbsd.org>2015-01-09 04:59:54 +0000
commit5dbc060c675a156bed9dc857ba47c688e92d9bbb (patch)
tree23392a5d96ebdca88555ffa26bfafe22bac061a9
parentCleanup some macros and #defines in i386 pmap. Previously committed and (diff)
downloadwireguard-openbsd-5dbc060c675a156bed9dc857ba47c688e92d9bbb.tar.xz
wireguard-openbsd-5dbc060c675a156bed9dc857ba47c688e92d9bbb.zip
correctly handle no timeouts and make timeout handling in general better.
problem reported by Mages Simon ok guenther
-rw-r--r--sys/net/bpf.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c
index bbd9a59a265..361a283e2e5 100644
--- a/sys/net/bpf.c
+++ b/sys/net/bpf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bpf.c,v 1.113 2014/12/16 18:30:04 tedu Exp $ */
+/* $OpenBSD: bpf.c,v 1.114 2015/01/09 04:59:54 tedu Exp $ */
/* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */
/*
@@ -430,10 +430,13 @@ bpfread(dev_t dev, struct uio *uio, int ioflag)
if (d->bd_rtout == -1) {
/* User requested non-blocking I/O */
error = EWOULDBLOCK;
+ } else if (d->bd_rtout == 0) {
+ error = tsleep(d, PRINET|PCATCH, "bpf", 0);
} else {
- if ((d->bd_rdStart + d->bd_rtout) < ticks) {
- error = tsleep((caddr_t)d, PRINET|PCATCH, "bpf",
- d->bd_rtout);
+ int elapsed = ticks - d->bd_rdStart;
+ if (elapsed < d->bd_rtout) {
+ error = tsleep(d, PRINET|PCATCH, "bpf",
+ d->bd_rtout - elapsed);
} else
error = EWOULDBLOCK;
}