USB backend loops on Solaris #3028

Closed
michaelrsweet opened this Issue Dec 1, 2008 · 7 comments

Comments

Projects
None yet
1 participant
Collaborator

michaelrsweet commented Dec 1, 2008

Version: 1.3.9
CUPS.org User: njacobs

The short version is that the USB backend always goes into an infinite loop in backendRunLoop().

The somewhat more long winded explaination is that the usbprn driver doesn't support poll (unless using ugen(7D)) causing select() on the device FD to always fail with errno set to ENXIO. Since the USB backend calls backendRunLoop() with use_bc set to 1 and and a side_cb, the device is added to the list of FDs to select on.

This can be "fixed" by patching usb-unix.c to always pass use_bc=0 and size_cb=NULL when calling backendRunLoop(). Perhaps not an ideal fix, but a workable one. When CUPS goes to 1.4 and the USB backend supports libusb, that will be the preferred method of communicating with USB printers. That should avoid the issue all together, though I haven't verified that yet.

At any rate, a patch for 1.3.X is attached.

Collaborator

michaelrsweet commented Dec 2, 2008

CUPS.org User: mike

Hmm, the problem is that we also use select() to know when the device can accept more data. So, does the driver just not support backchannel select() or select in general?

If so, we'll just have to drop Solaris USB prn support in 1.3.x and rely on the new libusb stuff from 1.4 instead.

Collaborator

michaelrsweet commented Dec 2, 2008

CUPS.org User: njacobs

usbprn(7d) on Solaris only supports poll when using the ugen interface, so basically, if you are just using /dev/printers/* or /dev/usb/printer*, select(3C) doesn't work. However, you shouldn't need to select on the device fd. The write to the printer should block if it's not ready for data. Not exactly ideal, but it still appears to be functional.

Collaborator

michaelrsweet commented Dec 3, 2008

CUPS.org User: mike

We can't block on writes and still support back-channel or side-channel stuff... Similarly, we don't want to use non-blocking IO as that kills performance.

Can you point me at the ugen interface information? Is it something we can use directly as a character device for printing, or is it the generic USB interface that we'd ultimately be using via libusb?

Like I said, we might just need to drop usbprn support on Solaris...

Collaborator

michaelrsweet commented Dec 3, 2008

CUPS.org User: njacobs

I have filed a bug against the usbprn driver asking for poll support and it's been picked up the the USB driver owner, so the support may ultimately be added. As far as the ugen interface goes, the following link describes it's use http://developers.sun.com/solaris/developer/support/driver/docs/usbups_whitepaper.html The easier and more portable way to use it appears to be to use libusb instead of ugen directly.

Collaborator

michaelrsweet commented Dec 5, 2008

CUPS.org User: mike

Fixed in Subversion repository.

The attached fix is a little different from yours - we want to make the use_bc choice earlier so that we just open the USB device write-only...

Collaborator

michaelrsweet commented Dec 5, 2008

"08-usb-hack.patch":

*** backend/usb-unix.c.orig Tue Nov 25 12:32:12 2008
--- backend/usb-unix.c Wed Nov 26 00:19:33 2008


*** 173,179 ****
--- 173,188 ----
lseek(print_fd, 0, SEEK_SET);
}

  • #ifdef __sun

  • /*

  • \* *Solaris's usbrn driver doesn't currently support the poll() interface
    
  • \* which causes select() to always fail with errno set to ENXIO, so
    
  • \* we don't want back channel or side channel support.
    
  • */
    
  • tbytes = backendRunLoop(print_fd, device_fd, 0, NULL);
    
  • #else
    tbytes = backendRunLoop(print_fd, device_fd, use_bc, side_cb);

  • #endif

    if (print_fd != 0 && tbytes >= 0)
    _cupsLangPrintf(stderr,

Collaborator

michaelrsweet commented Dec 5, 2008

"str3028-1.3.patch":

Index: backend/usb-unix.c

--- backend/usb-unix.c (revision 8154)
+++ backend/usb-unix.c (working copy)
@@ -80,6 +80,14 @@

 use_bc = 0;

+#elif defined(__sun)

  • /*
  • * CUPS STR #3028: Solaris' usbprn driver apparently does not support
  • * select() or poll(), so we can't support backchannel...
  • */
  • use_bc = 0;

#else
/*

  • Disable backchannel data when printing to Brother, Canon, or
    @@ -173,7 +181,17 @@
    lseek(print_fd, 0, SEEK_SET);
    }

+#ifdef __sun

  • /*
  • * CUPS STR #3028: Solaris' usbprn driver apparently does not support
  • * select() or poll(), so we can't support the sidechannel either...
  • */
  • tbytes = backendRunLoop(print_fd, device_fd, use_bc, NULL);

+#else
tbytes = backendRunLoop(print_fd, device_fd, use_bc, side_cb);
+#endif /* __sun */

if (print_fd != 0 && tbytes >= 0)
_cupsLangPrintf(stderr,

michaelrsweet added this to the Stable milestone Mar 17, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment