Package: libusb / 2:0.1.12-25

04_infinite_loop.diff Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
---
 linux.c |   12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

--- a/linux.c
+++ b/linux.c
@@ -213,15 +213,21 @@
       return ret;
     }
 
-    FD_ZERO(&writefds);
-    FD_SET(dev->fd, &writefds);
-
 restart:
     waiting = 1;
     context = NULL;
     while (!urb.usercontext && ((ret = ioctl(dev->fd, IOCTL_USB_REAPURBNDELAY, &context)) == -1) && waiting) {
+      if (ret == -1)
+      {
+        if (errno == ENODEV)
+        {
+          return -ENODEV;
+        }
+      }
       tv.tv_sec = 0;
       tv.tv_usec = 1000; // 1 msec
+      FD_ZERO(&writefds);
+      FD_SET(dev->fd, &writefds);
       select(dev->fd + 1, NULL, &writefds, NULL, &tv); //sub second wait
 
       if (timeout) {