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

Michael Sweet msweet at apple.com
Fri Feb 5 08:40:54 PST 2010


On Feb 5, 2010, at 3:55 AM, Tim Waugh wrote:
> 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?:

Because some printers break when we do this (more specifically, as soon as we shutdown our side of the connection they decide to do the same with their side instead of sending any remaining back-channel data...)

However, the reasons for keeping this workaround in place (waiting for back-channel data) are going away soon, so maybe in CUPS 1.5 (at least) we can just remove the extra "wait for back-channel data" code since it isn't needed in the general case - just for drivers or "auto-setup tools" on Mac OS X that close their stdout pipe when they are done sending data but not done reading a response.

Care to file a bug?

___________________________________________________
Michael Sweet, Senior Printing System Engineer







More information about the cups mailing list