[cups.general] socket backend: why not call shutdown immediately?

Tim Waugh twaugh at redhat.com
Fri Feb 5 03:55:33 PST 2010


When the socket backend has send the print file, it waits for up to 5
seconds to collect pending back-channel data, like this:

 /*
  * Wait up to 5 seconds to get any pending back-channel data...
  */

  wait_time = time(NULL) + 5;
  while (wait_time >= time(&current_time))
    if (wait_bc(device_fd, wait_time - current_time) <= 0)
      break;

After that, if the waiteof option is set (which it is by default), it
shuts down the socket and waits for the device to close the connection,
like this:

    shutdown(device_fd, 1);

    while (wait_bc(device_fd, 90) > 0);

My question is: why don't we shutdown the connection first of all, like
this?:

 /*
  * Wait up to 5 seconds to get any pending back-channel data...
  */

  shutdown(device_fd, SHUT_WR);
  wait_time = time(NULL) + 5;
  while (wait_time >= time(&current_time))
    if (wait_bc(device_fd, wait_time - current_time) <= 0)
      break;

If the printer has back-channel data to send, we aren't stopping it from
doing that.  Some devices do not close their end of the connection until
we close our end, so delaying the shutdown() call just wastes time in
that case.

Tim.
*/

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part
URL: <https://lists.cups.org/pipermail/cups/attachments/20100205/26cebd64/attachment.bin>


More information about the cups mailing list