hplip/hplip-device-reconnected.patch
Tim Waugh a9040f4755 - 3.9.10. No longer need clear-previous-state-reasons, hpcups-reorder,
non-scripts, parenths, plugin-error, requirespageregion or
    state-reasons-newline patches.
2009-11-04 16:43:29 +00:00

37 lines
1.4 KiB
Diff

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. */