rpms/cups/devel cups-usb-paperout.patch, NONE, 1.1 cups.spec, 1.327, 1.328

fedora-cvs-commits at redhat.com fedora-cvs-commits at redhat.com
Wed Apr 25 17:10:18 UTC 2007


Author: twaugh

Update of /cvs/dist/rpms/cups/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv19388

Modified Files:
	cups.spec 
Added Files:
	cups-usb-paperout.patch 
Log Message:
* Wed Apr 25 2007 Tim Waugh <twaugh at redhat.com> 1:1.2.10-7
- Until bug #236736 is fixed, work around the kernel usblp driver's
  quirks so that we can detect paper-out conditions.
- Resolves: rhbz#236736


cups-usb-paperout.patch:
 runloop.c  |   49 +++++++++++++++++++++++++++++++++++++++++++++++++
 usb-unix.c |   16 ++++++++++++++++
 2 files changed, 65 insertions(+)

--- NEW FILE cups-usb-paperout.patch ---
--- cups-1.2.10/backend/runloop.c.usb-paperout	2006-12-06 20:10:16.000000000 +0000
+++ cups-1.2.10/backend/runloop.c	2007-04-25 18:00:59.000000000 +0100
@@ -40,6 +40,14 @@
 #endif /* __hpux */
 
 
+#ifdef __linux
+#include <sys/ioctl.h>
+#include <linux/lp.h>
+#include <time.h>
+int linux_usb_paperout_hack = 0;
+#endif /* __linux */
+
+
 /*
  * 'backendRunLoop()' - Read and write print and back-channel data.
  */
@@ -64,6 +72,9 @@
 #if defined(HAVE_SIGACTION) && !defined(HAVE_SIGSET)
   struct sigaction action;		/* Actions for POSIX signals */
 #endif /* HAVE_SIGACTION && !HAVE_SIGSET */
+#ifdef __linux
+  time_t	last_write = 0;		/* Last time write() succeeded */
+#endif /* __linux */
 
 
   fprintf(stderr, "DEBUG: backendRunLoop(print_fd=%d, device_fd=%d, use_bc=%d)\n",
@@ -227,6 +238,9 @@
       }
       else
       {
+#ifdef __linux
+	last_write = time (NULL);
+#endif /* __linux */
         if (paperout)
 	{
 	  fputs("STATE: -media-empty-error\n", stderr);
@@ -247,7 +261,42 @@
 	total_bytes += bytes;
       }
     }
+
+#ifdef __linux
+    if (linux_usb_paperout_hack)
+    {
+      time_t now;
+      if (!paperout &&
+	  ((now = time(NULL)) - last_write) > 5)
+      {
+	unsigned int status;
+	if (ioctl (device_fd, LPGETSTATUS, &status) == 0 &&
+	    (status & LP_POUTPA))
+	{
+	  fputs("ERROR: Out of paper!\n", stderr);
+	  fputs("STATE: +media-empty-error\n", stderr);
+	  paperout = 1;
+	}
+
+	/* Don't check status for another 5s. */
+	last_write = now;
+      }
+    }
+#endif /* __linux */
+  }
+
+#ifdef __linux
+  if (linux_usb_paperout_hack)
+  {
+    /* Wait for the last write() to finish. */
+    do
+    {
+      FD_ZERO(&output);
+      FD_SET(device_fd, &output);
+    } while (select(device_fd + 1, NULL, &output, NULL, NULL) < 0 &&
+	     errno == EINTR);
   }
+#endif /* __linux */
 
  /*
   * Return with success...
--- cups-1.2.10/backend/usb-unix.c.usb-paperout	2007-04-25 17:50:06.000000000 +0100
+++ cups-1.2.10/backend/usb-unix.c	2007-04-25 17:50:06.000000000 +0100
@@ -39,6 +39,11 @@
 #include "ieee1284.c"
 #include <sys/select.h>
 
+#ifdef __linux
+#include <unistd.h>
+#include <fcntl.h>
+extern int linux_usb_paperout_hack;
+#endif /* __linux */
 
 /*
  * Local functions...
@@ -70,6 +75,11 @@
   (void)argc;
   (void)argv;
 
+#ifdef __linux
+  /* Get the runloop to check for USB paper-out condition. */
+  linux_usb_paperout_hack = 1;
+#endif /* __linux */
+
  /*
   * Open the USB port device...
   */
@@ -150,6 +160,12 @@
 
   tcsetattr(device_fd, TCSANOW, &opts);
 
+#ifdef __linux
+  /* Put the file descriptor into non-blocking mode so that we
+   * get a chance to detect paper-out. */
+  fcntl (device_fd, F_SETFL, fcntl (device_fd, F_GETFL) | O_NONBLOCK);
+#endif /* __linux */
+
  /*
   * Finally, send the print file...
   */


Index: cups.spec
===================================================================
RCS file: /cvs/dist/rpms/cups/devel/cups.spec,v
retrieving revision 1.327
retrieving revision 1.328
diff -u -r1.327 -r1.328
--- cups.spec	10 Apr 2007 10:52:58 -0000	1.327
+++ cups.spec	25 Apr 2007 17:10:11 -0000	1.328
@@ -6,7 +6,7 @@
 Summary: Common Unix Printing System
 Name: cups
 Version: 1.2.10
-Release: 6%{?dist}
+Release: 7%{?dist}
 License: GPL
 Group: System Environment/Daemons
 Source: ftp://ftp.easysw.com/pub/cups/%{version}/cups-%{version}-source.tar.bz2
@@ -46,6 +46,7 @@
 Patch22: cups-af_unix-auth.patch
 Patch23: cups-str2323.patch
 Patch24: cups-str2109.patch
+Patch25: cups-usb-paperout.patch
 Patch100: cups-lspp.patch
 Epoch: 1
 Url: http://www.cups.org/
@@ -154,6 +155,7 @@
 %patch22 -p1 -b .af_unix-auth
 %patch23 -p1 -b .str2323
 %patch24 -p1 -b .str2109
+%patch25 -p1 -b .usb-paperout
 
 %if %lspp
 %patch100 -p1 -b .lspp
@@ -440,6 +442,10 @@
 %{cups_serverbin}/daemon/cups-lpd
 
 %changelog
+* Wed Apr 25 2007 Tim Waugh <twaugh at redhat.com> 1:1.2.10-7
+- Until bug #236736 is fixed, work around the kernel usblp driver's
+  quirks so that we can detect paper-out conditions.
+
 * Tue Apr 10 2007 Tim Waugh <twaugh at redhat.com> 1:1.2.10-6
 - Fixed 'cancel' man page (bug #234088).
 - Added empty subscriptions.conf file to make sure it gets the right




More information about the fedora-cvs-commits mailing list