]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
An optimization: If there are no request_header_access directives
authorwessels <>
Sat, 5 Nov 2005 03:23:18 +0000 (03:23 +0000)
committerwessels <>
Sat, 5 Nov 2005 03:23:18 +0000 (03:23 +0000)
configured, then don't loop through the headers for each request,
creating and destroying ACL-related objects that are never used.

src/HttpHeaderTools.cc
src/cache_cf.cc
src/http.cc
src/protos.h
src/structs.h

index 9b223e3fccc6cd3c880c9ca05382c92b66ae6cb0..4b7fd895050068becae2048b3060c4044dee43d5 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpHeaderTools.cc,v 1.50 2005/09/17 05:50:07 wessels Exp $
+ * $Id: HttpHeaderTools.cc,v 1.51 2005/11/04 20:23:18 wessels Exp $
  *
  * DEBUG: section 66    HTTP Header Tools
  * AUTHOR: Alex Rousskov
@@ -555,3 +555,18 @@ httpHdrMangleList(HttpHeader * l, HttpRequest * request, int req_or_rep)
         if (0 == httpHdrMangle(e, request, req_or_rep))
             httpHeaderDelAt(l, p);
 }
+
+/*
+ * return 1 if manglers are configured.  Used to set a flag
+ * for optimization during request forwarding.
+ */
+int
+httpHdrManglersConfigured()
+{
+    for (int i = 0; i < HDR_ENUM_END; i++) {
+        if (NULL != Config.request_header_access[i].access_list)
+            return 1;
+    }
+
+    return 0;
+}
index 7a01ca4c75315381e84864725945abf9721b1ecf..ce240fc2bd7d3e86f8a2b490587b11cfa71e8dc3 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cache_cf.cc,v 1.483 2005/10/28 18:49:46 serassio Exp $
+ * $Id: cache_cf.cc,v 1.484 2005/11/04 20:23:18 wessels Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -601,6 +601,8 @@ configDoConfigure(void)
     if (aclPurgeMethodInUse(Config.accessList.http))
         Config2.onoff.enable_purge = 1;
 
+    Config2.onoff.mangle_headers = httpHdrManglersConfigured();
+
     if (geteuid() == 0) {
         if (NULL != Config.effectiveUser) {
 
index a7a3a62271ccddcaee369f1088ea49c78808fb06..946b212e712c075c51087516da2f7568a9ec6f43 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: http.cc,v 1.462 2005/10/18 19:55:28 serassio Exp $
+ * $Id: http.cc,v 1.463 2005/11/04 20:23:18 wessels Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -1448,7 +1448,8 @@ httpBuildRequestHeader(HttpRequest * request,
     }
 
     /* Now mangle the headers. */
-    httpHdrMangleList(hdr_out, request, ROR_REQUEST);
+    if (Config2.onoff.mangle_headers)
+        httpHdrMangleList(hdr_out, request, ROR_REQUEST);
 
     strConnection.clean();
 }
index 1f63b30439c96f55db2edf54632ce894834e3157..c3322ddfc5b2384723fd586a98c2d882d53c4e86 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.511 2005/09/15 19:04:56 wessels Exp $
+ * $Id: protos.h,v 1.512 2005/11/04 20:23:18 wessels Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -432,6 +432,7 @@ SQUIDCEXTERN void httpHeaderEntryPackInto(const HttpHeaderEntry * e, Packer * p)
 /* store report about current header usage and other stats */
 SQUIDCEXTERN void httpHeaderStoreReport(StoreEntry * e);
 SQUIDCEXTERN void httpHdrMangleList(HttpHeader *, HttpRequest *, int req_or_rep);
+SQUIDCEXTERN int httpHdrManglersConfigured();
 
 SQUIDCEXTERN void icmpOpen(void);
 SQUIDCEXTERN void icmpClose(void);
index a9d2b5dcf394c8fa8175e6ed6a2057e3bb0807c1..dc228e369c9c9ab5ac546851cae20af414c1792d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.529 2005/09/25 20:25:56 hno Exp $
+ * $Id: structs.h,v 1.530 2005/11/04 20:23:18 wessels Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -762,6 +762,7 @@ struct _SquidConfig2
     struct
     {
         int enable_purge;
+        int mangle_headers;
     }
 
     onoff;