File 10856.patch of Package squid-beta

---------------------
PatchSet 10856 
Date: 2007/06/19 21:03:45
Author: rousskov
Branch: HEAD
Tag: (none) 
Log:
Added icap_connect_timeout and icap_io_timeout squid.conf options to control
how long an ICAP transaction should wait for the ICAP server to accept its
connection or process the next I/O. These options are needed for many optional
ICAP services that are poorly reachable or otherwise delay network I/Os.
Waiting for a service is harmful to user experience, especially when the
service failure or lack of connectivity can be bypassed.

The two knobs use HTTP option values as defaults and have different defaults
for essential and optional services. This may be a bad idea and will change
depending on user feedback.

All timeouts are currently global. Eventually, we will need per-service or
service group timeouts and, possibly, even an OPTIONS-specific timeout.

Merged from the squid3-icap branch.

Members: 
	src/cf.data.pre:1.438->1.439 
	src/ICAP/ICAPConfig.cc:1.16->1.17 
	src/ICAP/ICAPConfig.h:1.13->1.14 

Index: squid3/src/cf.data.pre
===================================================================
RCS file: /cvsroot/squid/squid3/src/cf.data.pre,v
retrieving revision 1.438
retrieving revision 1.439
diff -u -r1.438 -r1.439
--- squid3/src/cf.data.pre	26 May 2007 06:38:03 -0000	1.438
+++ squid3/src/cf.data.pre	19 Jun 2007 21:03:45 -0000	1.439
@@ -1,6 +1,6 @@
 
 #
-# $Id: cf.data.pre,v 1.438 2007/05/26 06:38:03 wessels Exp $
+# $Id: cf.data.pre,v 1.439 2007/06/19 21:03:45 rousskov Exp $
 #
 #
 # SQUID Web Proxy Cache		http://www.squid-cache.org/
@@ -4997,6 +4997,36 @@
     If you want to enable the ICAP module support, set this to on.
 DOC_END
 
+NAME: icap_connect_timeout
+TYPE: time_t
+DEFAULT: none
+LOC: TheICAPConfig.connect_timeout_raw
+IFDEF: ICAP_CLIENT
+DOC_START
+	This parameter specifies how long to wait for the TCP connect to
+	the requested ICAP server to complete before giving up and either
+	terminating the HTTP transaction or bypassing the failure.
+
+	The default for optional services is peer_connect_timeout.
+	The default for essential services is connect_timeout.
+	If this option is explicitly set, its value applies to all services.
+DOC_END
+
+NAME: icap_io_timeout
+COMMENT: time-units
+TYPE: time_t
+DEFAULT: none
+LOC: TheICAPConfig.io_timeout_raw
+IFDEF: ICAP_CLIENT
+DOC_START
+	This parameter specifies how long to wait for an I/O activity on
+	an established, active ICAP connection before giving up and
+	either terminating the HTTP transaction or bypassing the
+	failure.
+
+	The default is read_timeout.
+DOC_END
+
 NAME: icap_service_failure_limit
 TYPE: int
 IFDEF: ICAP_CLIENT
Index: squid3/src/ICAP/ICAPConfig.cc
===================================================================
RCS file: /cvsroot/squid/squid3/src/ICAP/ICAPConfig.cc,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- squid3/src/ICAP/ICAPConfig.cc	29 May 2007 13:31:43 -0000	1.16
+++ squid3/src/ICAP/ICAPConfig.cc	19 Jun 2007 21:03:46 -0000	1.17
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ICAPConfig.cc,v 1.16 2007/05/29 13:31:43 amosjeffries Exp $
+ * $Id: ICAPConfig.cc,v 1.17 2007/06/19 21:03:46 rousskov Exp $
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
  * ----------------------------------------------------------
@@ -431,3 +431,20 @@
     classes.clean();
 
 };
+
+time_t ICAPConfig::connect_timeout(bool bypassable) const
+{
+    if (connect_timeout_raw > 0)
+        return connect_timeout_raw; // explicitly configured
+
+    return bypassable ? Config.Timeout.peer_connect : Config.Timeout.connect;
+}
+
+time_t ICAPConfig::io_timeout(bool) const
+{
+    if (io_timeout_raw > 0)
+        return io_timeout_raw; // explicitly configured
+    // TODO: provide a different default for an ICAP transaction that 
+    // can still be bypassed
+    return Config.Timeout.read; 
+}
Index: squid3/src/ICAP/ICAPConfig.h
===================================================================
RCS file: /cvsroot/squid/squid3/src/ICAP/ICAPConfig.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- squid3/src/ICAP/ICAPConfig.h	29 May 2007 13:31:44 -0000	1.13
+++ squid3/src/ICAP/ICAPConfig.h	19 Jun 2007 21:03:46 -0000	1.14
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ICAPConfig.h,v 1.13 2007/05/29 13:31:44 amosjeffries Exp $
+ * $Id: ICAPConfig.h,v 1.14 2007/06/19 21:03:46 rousskov Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -96,6 +96,8 @@
     int onoff;
     int preview_enable;
     int preview_size;
+    time_t connect_timeout_raw;
+    time_t io_timeout_raw;
     int default_options_ttl;
     int send_client_ip;
     int send_client_username;
@@ -112,6 +114,9 @@
 
     ~ICAPConfig();
 
+    time_t connect_timeout(bool bypassable) const;
+    time_t io_timeout(bool bypassable) const;
+
     void parseICAPService(void);
     void freeICAPService(void);
     void dumpICAPService(StoreEntry *, const char *);