Sophie

Sophie

distrib > Mageia > 1 > i586 > media > core-release-src > by-pkgid > 2c101d732df8a963b38a7c700d61af5a > files > 19

hplip-3.11.3a-5.mga1.src.rpm

diff -up hplip-3.9.10/prnt/backend/hp.c.device-reconnected hplip-3.9.10/prnt/backend/hp.c
--- hplip-3.9.10/prnt/backend/hp.c.device-reconnected	2009-11-03 21:45:10.000000000 +0000
+++ hplip-3.9.10/prnt/backend/hp.c	2009-11-04 16:25:30.719129509 +0000
@@ -645,6 +645,7 @@ int main(int argc, char *argv[])
    HPMUD_DEVICE hd=-1;
    HPMUD_CHANNEL cd=-1;
    int n, total=0, retry=0, size, pages;
+   int consecutive_failures=0;
    enum HPMUD_RESULT stat;
    char *printer = getenv("PRINTER"); 
    
@@ -809,11 +810,24 @@ int main(int argc, char *argv[])
                {
                   exit_stat = BACKEND_STOP;  /* stop queue */
                   goto bugout;
+	       }
+
+	       if (++consecutive_failures == 5)
+	       {
+		 /* hpmud_write_channel has failed several times in
+		  * succession but the Device ID-based status says
+		  * the printer is happy.  Time to face the fact that
+		  * the device has probably reconnected, and our USB
+		  * channel is invalidated. */
+
+		 BUG("ERROR: device reconnected?");
+		 goto bugout;
                }
             }
             else
             {
                /* Data was sent to device successfully. */ 
+               consecutive_failures = 0;
                if (pa.pjl_device)
                {
                   /* Laserjets have a large data buffer, so manually check for operator intervention condition. */