backend runloop spins on backchannel EOF #3001

michaelrsweet opened this Issue Nov 13, 2008 · 4 comments


None yet
1 participant

michaelrsweet commented Nov 13, 2008

Version: 1.3.9 User: martin.pitt.canonical reported that 1.3.9 does not print anything when using HPJetDirect. Instead, the socket backend uses 100% CPU and just keeps spinning.

strace shows that it's spinning in the device_fd (backchannel) loop:

19284 select(6, [4 5], [5], NULL, NULL) = 1 (in [5])
19284 read(5, "", 1024)

Samuel Thibault tracked this down to a bug in backendRunLoop(): As stated in the manpage, select() reports an fd as "ready for reading" if it is EOF (i. e. read() returns 0). The current code does not intercept this and just keeps select()ing and read()ing. He also provided a patch to stop reading from device_fd on EOF.

The patch looks good and correct to me. It was confirmed to fix the printing (see Debian bug report trail).


michaelrsweet commented Nov 14, 2008 User: mike

Um, if the backchannel is closed, then we should stop immediately as that is an error condition.


michaelrsweet commented Nov 14, 2008 User: mike

Fixed in Subversion repository.

Please test the attached alternate patch, which logs the read error and then disables back-channel reads until the job is done or we fail on a write...


michaelrsweet commented Nov 20, 2008 User: martin.pitt.canonical

The reporters confirmed that this patch works fine. Thank you!


michaelrsweet commented Nov 27, 2008


Index: backend/runloop.c

--- backend/runloop.c (revision 8127)
+++ backend/runloop.c (working copy)
@@ -283,6 +283,12 @@
CUPS_LLCAST bc_bytes);
cupsBackChannelWrite(bc_buffer, bc_bytes, 1.0);

  •  else if (bc_bytes < 0 && errno != EAGAIN && errno != EINTR)
  •  {
  •    fprintf(stderr, "DEBUG: Error reading back-channel data: %s\n",
  •       strerror(errno));
  • use_bc = 0;

  •  }



@michaelrsweet 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