From: tedu Date: Fri, 9 Jan 2015 04:59:54 +0000 (+0000) Subject: correctly handle no timeouts and make timeout handling in general better. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=5dbc060c675a156bed9dc857ba47c688e92d9bbb;p=openbsd correctly handle no timeouts and make timeout handling in general better. problem reported by Mages Simon ok guenther --- 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; }