From f8813e6f8e9502347a2fb4388bee8c08cc2e585a Mon Sep 17 00:00:00 2001 From: tedu Date: Tue, 24 Dec 2013 23:29:38 +0000 Subject: [PATCH] rearrange/correct timeout conditionals to work better. fixes negative timeout panics. tested by sthen. --- sys/net/bpf.c | 17 ++++++++--------- 1 file 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); -- 2.20.1