diff options
author | Ted Unangst <tedu@cvs.openbsd.org> | 2013-12-24 23:29:39 +0000 |
---|---|---|
committer | Ted Unangst <tedu@cvs.openbsd.org> | 2013-12-24 23:29:39 +0000 |
commit | 6e99e2673b8aa7d46827a967c8ad9f84b9d9d8aa (patch) | |
tree | 483e8b92163a9564cac7d4f07aa16b787703eca3 /sys | |
parent | 46c6ff6f53cd364da09058ef22e7f198c0503a6c (diff) |
rearrange/correct timeout conditionals to work better.
fixes negative timeout panics. tested by sthen.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/bpf.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 0c84f978184..e150a2e795d 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.89 2013/11/29 19:28:55 tedu Exp $ */ +/* $OpenBSD: bpf.c,v 1.90 2013/12/24 23:29:38 tedu Exp $ */ /* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */ /* @@ -434,16 +434,15 @@ bpfread(dev_t dev, struct uio *uio, int ioflag) ROTATE_BUFFERS(d); break; } - if ((d->bd_rtout != -1) || - (d->bd_rdStart + d->bd_rtout) < ticks) { - error = tsleep((caddr_t)d, PRINET|PCATCH, "bpf", - d->bd_rtout); + if (d->bd_rtout == -1) { + /* User requested non-blocking I/O */ + error = EWOULDBLOCK; } else { - if (d->bd_rtout == -1) { - /* User requested non-blocking I/O */ - error = EWOULDBLOCK; + if ((d->bd_rdStart + d->bd_rtout) < ticks) { + error = tsleep((caddr_t)d, PRINET|PCATCH, "bpf", + d->bd_rtout); } else - error = 0; + error = EWOULDBLOCK; } if (error == EINTR || error == ERESTART) { D_PUT(d); |