wrong behaviour when icapReadTimeout occurs

From: Dmitry Adamushko <da@dont-contact.us>
Date: Tue, 21 Sep 2004 12:09:37 +0300

Hi,

Here's a small patch concerning the icap client's implementation in
squid-icap-2.5-200408092201.

A problem with the current one is as described below:

The problem occurs when a connection between the squid and a web server
is lost during a period of time (e.g. some segment of a network between
these two is broken), which is enough for the web server to close its
side of the connection (when all send()'s retransmissions failed), but
the Squid knows nothing about this.
The Squid closes such a connection when the httpReadTimeout() timeout
occurs, but at the same time the icapReadTimeout() timeout occurs too,
and the icap service's state becomes unreachable.
That's incorrectly. In that situation a icap server was just waiting for
further data chunks to get a completed file before checking.

I think, it's much more correctly to set an icap service to unreachable
state only when all data has been sent (including a final zero chunk
"0\r\n\r\n") or a preview request has been sent and, thus, the squid has
been waiting for an answer before timeout occurs.

This problem had place on a server of our client. And I could repeat it
by the following steps on my machine:
- begin to download a big file;
- switch off the network cable on my machine for some minutes.

It works well when this patch applyed.

-- 
Best regards,
Dmitry Adamushko	mailto: da@vba.com.by

diff -r -u squid-icap-2.5-200408092201/src/icap_common.c squid-icap-2.5-200408092201-dimm3/src/icap_common.c
--- squid-icap-2.5-200408092201/src/icap_common.c 2004-04-04 00:12:55.000000000 +0300
+++ squid-icap-2.5-200408092201-dimm3/src/icap_common.c 2004-09-21 10:54:18.000000000 +0300
@@ -282,9 +282,12 @@
 icapReadTimeout(int fd, void *data)
 {
     IcapStateData *icap = data;
- debug(81, 3) ("icapReadTimeout: FD %d, unreachable=1\n", fd);
     assert(fd == icap->icap_fd);
- icapOptSetUnreachable(icap->current_service);
+ if (icap->flags.wait_for_preview_reply || icap->flags.http_server_eof) {
+ debug(81, 3) ("icapReadTimeout: FD %d, unreachable=1\n", fd);
+ icapOptSetUnreachable(icap->current_service);
+ } else
+ debug(81, 3) ("icapReadTimeout: FD %d, still reachable\n", fd);
     comm_close(fd);
 }
 
Received on Tue Sep 21 2004 - 04:11:19 MDT

This archive was generated by hypermail pre-2.1.9 : Thu Sep 30 2004 - 12:00:04 MDT