Peter van Heusden
2007-May-03 15:06 UTC
[cups.bugs] tcgetattr() causes lockup in USB backend on FreeBSD6-STABLE
Sorry, a bit more investigation revealed that my earlier comments were wrong. Yes, the tcgetattr() call *does* "hang" - on my system it takes 10 seconds to return, before returning ENODEV (the only thing that ioctl on a ulpt returns on FreeBSD, according to my reading of the kernel). That, however, isn't the real problem - the real hang occurs when backendRunLoop() in runloop.c tries to read backchannel data from the ulpt - despite select() saying that there is data available, the read() blocks (I've even tried making the read buffer's size 1 byte, the problem persists). This causes the usb backend hang. So indeed, setting use_bc = 0 solves the problem. I'm not sure why select() / read() interact like this. Peter Michael Sweet wrote:> Peter van Heusden wrote: > >> I recently upgrade CUPS on my FreeBSD 6-STABLE server to version 1.2.10, >> and it took a while to get the USB backend working (I have a USB-connect >> HP LaserJet 1010). After some debugging, it turned out that the code in >> usb-unix.c that calls tcgetattr() on /dev/ulptN in print_device() was at >> fault - what happens is that tcgetattr() blocks, and the USB backend >> then hangs. I'm still waiting for a response from the FreeBSD developers >> on this behaviour, but in any event from my reading of the kernel it >> seems that ioctl() on a FreeBSD ulpt is a no-op anyway. >> > > The use_bc stuff doesn't control whether ioctl() (via tcget/setattr) > is used to set "raw" mode, so a separate fix will be needed. > > That said, this sounds like a serious FreeBSD bug - ioctl is needed > for POSIX conformance on all character devices. > >
Eygene Ryabinkin
2007-May-03 15:32 UTC
[cups.bugs] tcgetattr() causes lockup in USB backend on FreeBSD6-STABLE
Peter, good day. Thu, May 03, 2007 at 05:06:13PM +0200, Peter van Heusden wrote:> Sorry, a bit more investigation revealed that my earlier comments were > wrong. Yes, the tcgetattr() call *does* "hang" - on my system it takes > 10 seconds to return, before returning ENODEV (the only thing that ioctl > on a ulpt returns on FreeBSD, according to my reading of the kernel). > That, however, isn't the real problem - the real hang occurs when > backendRunLoop() in runloop.c tries to read backchannel data from the > ulpt - despite select() saying that there is data available, the read() > blocks (I've even tried making the read buffer's size 1 byte, the > problem persists). This causes the usb backend hang. So indeed, setting > use_bc = 0 solves the problem. I'm not sure why select() / read() > interact like this.Seems like the FreeBSD kernel reports your device as the bi-directional one? I mean that 'dmesg | grep directi' shows something like 'ulpt0: using bi-directional mode'? If yes, then adding your device to the USB quirks as the uni-directional one should fix your problem. If you can rebuild the kernel, but don't know how to correct the quirks, send me the output of the 'usbdevs -v' with the printer plugged in and I will try to send you the patch for the USB quirks file. -- Eygene