Skip to contentSkip to conversation

CUPS 1.7.0: fix corrupted output for USB printers

PATCH In review Tim Waugh 2 participants 2 messages Nov 29, 2013 – Dec 2, 2013

lore
Share & tools
lore

Tim Waugh

author
#0 lore raw

PATCH 1/1 CUPS 1.7.0: fix corrupted output for USB printers

When using the usb backend, if a usb-1 printer connected to a usb-2 hub runs out of paper during the job the print output will be corrupted.
https://bugzilla.redhat.com/show_bug.cgi?id=1026914

This is due to using a 60 second timeout for the libusb_bulk_transfer() call. Timeout handling and retries are not reliable in every case, as described here:
https://bugzilla.redhat.com/show_bug.cgi?id=1035863

Quoting from that report:
==>
So TL;DR: this a known and unfixable problem, and the solution is to simply not cancel transfers (by setting a timeout) and then decide you want to finish the transfer after all. Either decide you want to really cancel the transfer, or just wait for it to finish normally. <==

Patch attached to change the timeout to 0 to wait indefinitely.

Tim.
*/

backend/usb-libusb.c renamed from backend/usb-libusb.c.usb-timeout +3 -3
diff -up cups-1.7.0/backend/usb-libusb.c.usb-timeout cups-1.7.0/backend/usb-libusb.c
@@ -496,7 +496,7 @@ print_device(const char *uri,		/* I - De
 	iostatus = libusb_bulk_transfer(g.printer->handle,
 					g.printer->write_endp,
 					print_buffer, g.print_bytes,
-					&bytes, 60000);
+					&bytes, 0);
        /*
 	* Ignore timeout errors, but retain the number of bytes written to
 	* avoid sending duplicate data...
@@ -519,7 +519,7 @@ print_device(const char *uri,		/* I - De
 	  iostatus = libusb_bulk_transfer(g.printer->handle,
 					  g.printer->write_endp,
 					  print_buffer, g.print_bytes,
-					  &bytes, 60000);
+					  &bytes, 0);
 	}
 
        /*
@@ -534,7 +534,7 @@ print_device(const char *uri,		/* I - De
 	  iostatus = libusb_bulk_transfer(g.printer->handle,
 					  g.printer->write_endp,
 					  print_buffer, g.print_bytes,
-					  &bytes, 60000);
+					  &bytes, 0);
         }
 
 	if (iostatus)
#1 lore raw

Tim,

Quoted 17 lines · Tim Waugh

When using the usb backend, if a usb-1 printer connected to a usb-2 hub runs out of paper during the job the print output will be corrupted.
https://bugzilla.redhat.com/show_bug.cgi?id=1026914

This is due to using a 60 second timeout for the libusb_bulk_transfer() call. Timeout handling and retries are not reliable in every case, as described here:
https://bugzilla.redhat.com/show_bug.cgi?id=1035863

Quoting from that report:
==>
So TL;DR: this a known and unfixable problem, and the solution is to simply not cancel transfers (by setting a timeout) and then decide you want to finish the transfer after all. Either decide you want to really cancel the transfer, or just wait for it to finish normally. <==

Quoted 1 line

Patch attached to change the timeout to 0 to wait indefinitely.

This mirrors what we do on OS X; will include this in CUPS 1.7.1.

Filed as:

    <rdar://problem/15564888> cups.org: Fix USB timeouts on Linux

_______________________________________________________________
Michael Sweet, Senior Printing System Engineer, PWG Chair