BUG in bpf ?

2014-12-17 Thread Mages Simon
Hi,

if BIOCGRTIMEOUT is set, we should wait for the timeout and not just
set EWOULDBLOCK. From my point of view the whole 'if' is unnecessary.

If the User doesn't set a timeout we have to wait anyway with tsleep()
and loop again. Well, and if the timeout is set, we should tsleep()
for the set timeout.


Index: sys/net//bpf.c
===
RCS file: /home/cvs/src/sys/net/bpf.c,v
retrieving revision 1.103
diff -u -p -u -r1.103 bpf.c
--- sys/net//bpf.c  12 Jul 2014 18:44:22 -  1.103
+++ sys/net//bpf.c  17 Dec 2014 08:10:18 -
@@ -434,11 +434,9 @@ bpfread(dev_t dev, struct uio *uio, int 
/* User requested non-blocking I/O */
error = EWOULDBLOCK;
} else {
-   if ((d-bd_rdStart + d-bd_rtout)  ticks) {
-   error = tsleep((caddr_t)d, PRINET|PCATCH, bpf,
-   d-bd_rtout);
-   } else
-   error = EWOULDBLOCK;
+   /* User requested timeout */
+   error = tsleep((caddr_t)d, PRINET|PCATCH, bpf,
+   d-bd_rtout);
}
if (error == EINTR || error == ERESTART) {
D_PUT(d);



Re: BUG in bpf ?

2014-12-17 Thread Philip Guenther
On Wed, Dec 17, 2014 at 12:55 AM, Mages Simon
mages.si...@googlemail.com wrote:
 if BIOCGRTIMEOUT is set, we should wait for the timeout and not just
 set EWOULDBLOCK. From my point of view the whole 'if' is unnecessary.

 If the User doesn't set a timeout we have to wait anyway with tsleep()
 and loop again. Well, and if the timeout is set, we should tsleep()
 for the set timeout.

No, that's wrong.  This is inside a while() loop; if that loop's
condition holds, do you want to sleep for the original length of time
(again) or only for the remaining time?


Philip Guenther