summaryrefslogtreecommitdiffstats
path: root/abs/extra-testing/cups/fix-infinite-usb-loop.patch
blob: bad179e8b40007570ecbfe1c07d90647c132bc63 (plain)
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
32
33
34
35
diff -urNad cups-1.4.0~/backend/usb-libusb.c cups-1.4.0/backend/usb-libusb.c
--- cups-1.4.0~/backend/usb-libusb.c	2009-08-08 00:24:14.000000000 +0200
+++ cups-1.4.0/backend/usb-libusb.c	2009-09-02 16:37:31.000000000 +0200
@@ -158,7 +158,7 @@
 
     while (poll(pfds, 2, -1) > 0)
     {
-      if (pfds[0].revents & POLLIN)
+      if (pfds[0].revents & (POLLIN + POLLHUP))
       {
 	if ((bytes = read(print_fd, buffer, sizeof(buffer))) > 0)
 	{
@@ -179,7 +179,12 @@
       }
 
       if (pfds[1].revents & POLLIN)
-        tbytes += side_cb(printer, print_fd);
+      {
+        if ((bytes = side_cb(printer, print_fd)) < 0)
+	  pfds[1].events = 0;		/* Filter has gone away... */
+	else
+          tbytes += bytes;
+      }
     }
   }
 
@@ -747,7 +752,7 @@
   if (cupsSideChannelRead(&command, &status, data, &datalen, 1.0))
   {
     _cupsLangPuts(stderr, _("WARNING: Failed to read side-channel request!\n"));
-    return (0);
+    return (-1);
   }
 
   switch (command)