Index: backend/scsi-linux.c =================================================================== --- backend/scsi-linux.c (revision 5239) +++ backend/scsi-linux.c (working copy) @@ -116,6 +116,8 @@ * Open the SCSI device file... */ + fprintf(stderr, "STATE: +connecting-to-device\n"); + do { if ((scsi_fd = open(resource, O_RDWR | O_EXCL)) == -1) @@ -157,6 +159,8 @@ } while (scsi_fd == -1); + fprintf(stderr, "STATE: -connecting-to-device\n"); + /* * Now that we are "connected" to the port, ignore SIGTERM so that we * can finish out any page data the driver sends (e.g. to eject the Index: backend/scsi-irix.c =================================================================== --- backend/scsi-irix.c (revision 5239) +++ backend/scsi-irix.c (working copy) @@ -103,6 +103,8 @@ * Open the SCSI device file... */ + fprintf(stderr, "STATE: +connecting-to-device\n"); + do { if ((scsi_fd = open(resource, O_RDWR | O_EXCL)) == -1) @@ -144,6 +146,8 @@ } while (scsi_fd == -1); + fprintf(stderr, "STATE: -connecting-to-device\n"); + /* * Now that we are "connected" to the port, ignore SIGTERM so that we * can finish out any page data the driver sends (e.g. to eject the Index: backend/usb-unix.c =================================================================== --- backend/usb-unix.c (revision 5239) +++ backend/usb-unix.c (working copy) @@ -82,6 +82,8 @@ * Open the USB port device... */ + fprintf(stderr, "STATE: +connecting-to-device\n"); + do { if ((fd = open_device(uri)) == -1) @@ -127,6 +129,8 @@ } while (fd < 0); + fprintf(stderr, "STATE: -connecting-to-device\n"); + /* * Set any options provided... */ Index: backend/usb-darwin.c =================================================================== --- backend/usb-darwin.c (revision 5239) +++ backend/usb-darwin.c (working copy) @@ -674,6 +674,9 @@ USBPrinterInfo *activePrinter = NULL; USBPrinterClassContext **classdriver; int countdown = INITIAL_LOG_INTERVAL; + + fprintf(stderr, "STATE: +connecting-to-device\n"); + do { /* */ @@ -746,6 +749,8 @@ return (status); } + fprintf(stderr, "STATE: -connecting-to-device\n"); + /* * Now that we are "connected" to the port, ignore SIGTERM so that we * can finish out any page data the driver sends (e.g. to eject the Index: backend/serial.c =================================================================== --- backend/serial.c (revision 5239) +++ backend/serial.c (working copy) @@ -223,6 +223,8 @@ * Open the serial port device... */ + fprintf(stderr, "STATE: +connecting-to-device\n"); + do { if ((fd = open(resource, O_WRONLY | O_NOCTTY | O_EXCL | O_NDELAY)) == -1) @@ -263,6 +265,8 @@ } while (fd < 0); + fprintf(stderr, "STATE: -connecting-to-device\n"); + /* * Set any options provided... */ Index: backend/lpd.c =================================================================== --- backend/lpd.c (revision 5239) +++ backend/lpd.c (working copy) @@ -644,6 +644,7 @@ * First try to reserve a port for this connection... */ + fprintf(stderr, "STATE: +connecting-to-device\n"); fprintf(stderr, "INFO: Attempting to connect to host %s for printer %s\n", hostname, printer); @@ -769,12 +770,15 @@ #ifdef __APPLE__ recoverable = 1; fprintf(stderr, "WARNING: recoverable: " + "Network host \'%s\' is busy, down, or " + "unreachable; will retry in 30 seconds...\n", + hostname); #else fprintf(stderr, "WARNING: " -#endif /* __APPLE__ */ "Network host \'%s\' is busy, down, or " "unreachable; will retry in 30 seconds...\n", hostname); +#endif /* __APPLE__ */ sleep(30); } else if (error == EADDRINUSE) @@ -790,10 +794,11 @@ #ifdef __APPLE__ recoverable = 1; perror("ERROR: recoverable: " + "Unable to connect to printer; will retry in 30 seconds..."); #else perror("ERROR: " + "Unable to connect to printer; will retry in 30 seconds..."); #endif /* __APPLE__ */ - "Unable to connect to printer; will retry in 30 seconds..."); sleep(30); } } @@ -812,6 +817,7 @@ } #endif /* __APPLE__ */ + fprintf(stderr, "STATE: -connecting-to-device\n"); fprintf(stderr, "INFO: Connected to %s...\n", hostname); fprintf(stderr, "DEBUG: Connected on ports %d (local %d)...\n", port, lport); Index: backend/ipp.c =================================================================== --- backend/ipp.c (revision 5239) +++ backend/ipp.c (working copy) @@ -507,6 +507,8 @@ * Try connecting to the remote server... */ + fprintf(stderr, "STATE: +connecting-to-device\n"); + do { fprintf(stderr, "INFO: Connecting to %s on port %d...\n", hostname, port); @@ -563,6 +565,7 @@ } while (http == NULL); + fprintf(stderr, "STATE: -connecting-to-device\n"); fprintf(stderr, "INFO: Connected to %s...\n", hostname); /* @@ -1242,8 +1245,8 @@ while ((bytes = cupsFileRead(in, buffer, sizeof(buffer))) > 0) if (cupsFileWrite(out, buffer, bytes) < bytes) { - fprintf(stderr, "ERROR: Unable to write %d bytes to \"%s\": %s\n", - bytes, filename, strerror(errno)); + fprintf(stderr, "ERROR: Unable to write " CUPS_LLFMT " bytes to \"%s\": %s\n", + CUPS_LLCAST bytes, filename, strerror(errno)); cupsFileClose(in); cupsFileClose(out); exit(CUPS_BACKEND_FAILED); Index: backend/ieee1394.c =================================================================== --- backend/ieee1394.c (revision 5239) +++ backend/ieee1394.c (working copy) @@ -140,6 +140,8 @@ * Try to open the printer device... */ + fprintf(stderr, "STATE: +connecting-to-device\n"); + do { if ((dev = ieee1394_open(argv[0])) == NULL) @@ -150,6 +152,8 @@ } while (dev == NULL); + fprintf(stderr, "STATE: -connecting-to-device\n"); + /* * Now that we are "connected" to the port, ignore SIGTERM so that we * can finish out any page data the driver sends (e.g. to eject the Index: backend/socket.c =================================================================== --- backend/socket.c (revision 5239) +++ backend/socket.c (working copy) @@ -256,6 +256,8 @@ while (copies > 0) { + fprintf(stderr, "STATE: +connecting-to-device\n"); + for (delay = 5;;) { if (!httpAddrConnect(addrlist, &fd)) @@ -304,6 +306,8 @@ break; } + fprintf(stderr, "STATE: -connecting-to-device\n"); + /* * Now that we are "connected" to the port, ignore SIGTERM so that we * can finish out any page data the driver sends (e.g. to eject the Index: backend/parallel.c =================================================================== --- backend/parallel.c (revision 5239) +++ backend/parallel.c (working copy) @@ -202,6 +202,8 @@ * Open the parallel port device... */ + fprintf(stderr, "STATE: +connecting-to-device\n"); + do { if ((fd = open(resource, O_WRONLY | O_EXCL)) == -1) @@ -247,6 +249,8 @@ } while (fd < 0); + fprintf(stderr, "STATE: -connecting-to-device\n"); + /* * Set any options provided... */ Index: scheduler/sysman.c =================================================================== --- scheduler/sysman.c (revision 5239) +++ scheduler/sysman.c (working copy) @@ -264,6 +264,7 @@ void cupsdUpdateSystemMonitor(void) { + int i; /* Looping var */ cupsd_sysevent_t sysevent; /* The system event */ cupsd_printer_t *p; /* Printer information */ @@ -278,15 +279,26 @@ if (sysevent.event & SYSEVENT_CANSLEEP) { /* - * If there are any active printers cancel the sleep request... + * If there are active printers that don't have the connecting-to-device + * printer-state-reason then cancel the sleep request (i.e. this reason + * indicates a job that is not yet connected to the printer)... */ for (p = (cupsd_printer_t *)cupsArrayFirst(Printers); p; p = (cupsd_printer_t *)cupsArrayNext(Printers)) + { if (p->job) - break; + { + for (i = 0; i < p->num_reasons; i ++) + if (!strcmp(p->reasons[i], "connecting-to-device")) + break; + if (!p->num_reasons || i >= p->num_reasons) + break; + } + } + if (p) { cupsdLogMessage(CUPSD_LOG_INFO,