Retry sending data on a broken connection.
@@ -982,19 +982,17 @@ run_ipp_usb_to_host(
{
if (poll(&poll_data, 1, 1000) > 0)
{
- papplLogPrinter(iface->printer, PAPPL_LOGLEVEL_DEBUG, "TOHOST%d: Reading from socket %d.", iface->number, iface->ipp_sock);
+// papplLogPrinter(iface->printer, PAPPL_LOGLEVEL_DEBUG, "TOHOST%d: Reading from socket %d.", iface->number, iface->ipp_sock);
if ((bytes = read(iface->ipp_sock, buffer, sizeof(buffer))) > 0)
{
- papplLogPrinter(iface->printer, PAPPL_LOGLEVEL_DEBUG, "TOHOST%d: Sending %d bytes.", iface->number, (int)bytes);
+ papplLogPrinter(iface->printer, PAPPL_LOGLEVEL_DEBUG, "TOHOST%d: Returning %d bytes.", iface->number, (int)bytes);
if (write(iface->ipp_to_host, buffer, (size_t)bytes) < 0)
{
- papplLogPrinter(iface->printer, PAPPL_LOGLEVEL_ERROR, "TOHOST%d: Error sending data to host: %s", iface->number, strerror(errno));
+ papplLogPrinter(iface->printer, PAPPL_LOGLEVEL_ERROR, "TOHOST%d: Error returning data to host: %s", iface->number, strerror(errno));
break;
}
- else
- papplLogPrinter(iface->printer, PAPPL_LOGLEVEL_DEBUG, "TOHOST%d: Success", iface->number);
}
else if (bytes < 0)
{
@@ -1045,6 +1043,8 @@ run_ipp_usb_to_printer(
while (!iface->printer->is_deleted && iface->printer->system->is_running)
{
if ((bytes = read(iface->ipp_to_printer, buffer, sizeof(buffer))) > 0)
+ {
+ do
{
if (iface->ipp_sock < 0)
{
@@ -1062,13 +1062,17 @@ run_ipp_usb_to_printer(
}
}
- papplLogPrinter(iface->printer, PAPPL_LOGLEVEL_DEBUG, "TOPRINTER%d: Writing %d bytes to socket %d.", iface->number, (int)bytes, iface->ipp_sock);
+ papplLogPrinter(iface->printer, PAPPL_LOGLEVEL_DEBUG, "TOPRINTER%d: Sending %d bytes to socket %d.", iface->number, (int)bytes, iface->ipp_sock);
if (write(iface->ipp_sock, buffer, (size_t)bytes) < 0)
{
- papplLogPrinter(iface->printer, PAPPL_LOGLEVEL_ERROR, "TOPRINTER%d: Unable to write data to socket: %s", iface->number, strerror(errno));
- break;
+ papplLogPrinter(iface->printer, PAPPL_LOGLEVEL_ERROR, "TOPRINTER%d: Unable to send data to socket: %s", iface->number, strerror(errno));
+ pthread_cancel(iface->host_thread);
+ close(iface->ipp_sock);
+ iface->ipp_sock = -1;
+ }
}
+ while (iface->ipp_sock < 0);
}
}
