[cups.bugs] [MOD] STR #4187: _cupsConnect() can return cached http connection which is already unusable

Petr Cvachoucek petr.cvachoucek at oracle.com
Wed Sep 12 06:51:53 PDT 2012


DO NOT REPLY TO THIS MESSAGE.  INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.

[STR New]

Hi all,
we have CUPS clients configured to print directly to remote CUPS server -
ie. we have /etc/cups/client.conf with ServerName pointing to our CUPS
server. And we see such unpleasant behavior:

1) first time the app does some request to libcups.so, the HTTP connection
is
   created and used - all works ok. The HTTP connection is not closed but
cached
   in _cupsGlobals.

2) The CUPS server has its timeout - if the connection is idle for some
time
   (the default is 5 minutes), it closes it. This can be verified for
example
   by netstat output on clients - the TCP connection state changes from
   ESTABLISHED to CLOSE_WAIT.

3) Next time the app does some request to libcups.so, the cached HTTP
connection
   is directly used - returned by _cupsConnect(). Request is sent (no
error
   produced) and when reading response, the recv() call gets ECONNRESET
and
   the request fails.

This is easy to reproduce. Start OpenOffice or LibreOffice,
open "File -> Printer Settings" dialog, close it and wait 5 minutes.
Then try to open it again - and the list of printers is empty.

The idea for fix is to check the TCP connection state in _cupsConnect()
and verify the connection is still in ESTABLISHED state. If its not then
close it - the _cupsConnect() will then re-create it.

I'm attaching the patch with the fix for Solaris - checking the TCP
connection
state is system-specific, so the real fix for upstream would have to add
the code for other supported platforms as well.

I understand the fix is not perfect - there's still chance for request to
fail
if the server closes the connection just after the client checks it. But
it is
not very invasive and improves the users experience a lot in this
scenario,
because otherwise this bug is hit always and is very annoying for users.

Link: http://www.cups.org/str.php?L4187
Version: 1.6-current
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: cupsconnect.patch
URL: <http://lists.cups.org/pipermail/cups-devel/attachments/20120912/982d51a8/attachment.ksh>


More information about the cups-devel mailing list