[Pkg-cups-devel] Bug#489045: cups: infinite loop, 100%CPU use, while trying to print with HPJetDirect

Samuel Thibault samuel.thibault at ens-lyon.org
Tue Nov 11 13:46:55 UTC 2008


Andreas Mohr, le Sun 02 Nov 2008 17:17:12 +0100, a écrit :
> The CUPS backend mechanism had issues before already
> (STR #2664, http://www.cups.org/str.php?L2664+P0+S-2+C0+I0+E0+M20+Q ):
> 
> ------------------------------------------------------------------------
> r7204 | mike | 2008-01-09 19:59:55 +0100 (Mi, 09 Jan 2008) | 3 lines
> 
> Don't select() on the output side of the device if we have a
> side-channel
> callback - this causes 100% CPU usage (STR #2664)

Right but here the issue is on the input side: device_fd got to EOF,
thus select() returning it and read() on it returning 0. The attached
patch at least prevents select from returning, avoiding 100% CPU usage.

Samuel
-------------- next part --------------
--- backend/runloop.c.orig	2008-11-11 14:38:02.000000000 +0100
+++ backend/runloop.c	2008-11-11 14:44:42.000000000 +0100
@@ -161,6 +161,7 @@
 #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
   struct sigaction action;		/* Actions for POSIX signals */
 #endif /* HAVE_SIGACTION && !HAVE_SIGSET */
+  int device_input = 1;
 
 
   fprintf(stderr,
@@ -210,7 +211,7 @@
     FD_ZERO(&input);
     if (!print_bytes)
       FD_SET(print_fd, &input);
-    if (use_bc)
+    if (use_bc && device_input)
       FD_SET(device_fd, &input);
     if (!print_bytes && side_cb)
       FD_SET(CUPS_SC_FD, &input);
@@ -273,6 +274,13 @@
 	        CUPS_LLCAST bc_bytes);
         cupsBackChannelWrite(bc_buffer, bc_bytes, 1.0);
       }
+      else if (bc_bytes == 0)
+      {
+       /*
+        * End of file, stop trying to read from device_fd
+	*/
+        device_input = 0;
+      }
     }
 
    /*


More information about the Pkg-cups-devel mailing list