]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Move clientCachable logic onto HttpRequest, as all the used fields in the
authorrobertc <>
Tue, 30 May 2006 03:44:18 +0000 (03:44 +0000)
committerrobertc <>
Tue, 30 May 2006 03:44:18 +0000 (03:44 +0000)
function where on the HttpRequest object.

Apply Gonzalo Aranas bugfix for the replacement to cachemgrRegister,
as having some options disabled/changed did not compile.

src/HttpRequest.cc
src/HttpRequest.h
src/Makefile.am
src/client_side_request.cc
src/comm_epoll.cc
src/main.cc
src/store_digest.cc
src/url.cc

index f2106aa1fc4eafc546dcb2f44996e0f156e3fe00..afa77032360caa4da0b6f1c8e9d40161628d6cec 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpRequest.cc,v 1.66 2006/05/08 23:38:33 robertc Exp $
+ * $Id: HttpRequest.cc,v 1.67 2006/05/29 21:44:18 robertc Exp $
  *
  * DEBUG: section 73    HTTP Request
  * AUTHOR: Duane Wessels
@@ -411,3 +411,48 @@ HttpRequest::CreateFromUrl(char * url)
 {
     return urlParse(METHOD_GET, url, NULL);
 }
+
+/*
+ * Are responses to this request possible cacheable ?
+ * If false then no matter what the response must not be cached.
+ */
+bool
+HttpRequest::cacheable() const
+{
+    if (protocol == PROTO_HTTP)
+        return httpCachable(method);
+
+    /* FTP is always cachable */
+
+    /* WAIS is never cachable */
+    if (protocol == PROTO_WAIS)
+        return 0;
+
+    /*
+     * The below looks questionable: what non HTTP protocols use connect,
+     * trace, put and post? RC
+     */
+    if (method == METHOD_CONNECT)
+        return 0;
+
+    if (method == METHOD_TRACE)
+        return 0;
+
+    if (method == METHOD_PUT)
+        return 0;
+
+    if (method == METHOD_POST)
+        return 0;
+
+    /*
+     * XXX POST may be cached sometimes.. ignored
+     * for now
+     */
+    if (protocol == PROTO_GOPHER)
+        return gopherCachable(this);
+
+    if (protocol == PROTO_CACHEOBJ)
+        return 0;
+
+    return 1;
+}
index 6add8ee3d3f2c6c2433e5fed26831539f66cf1e0..7327fdd294b5a4665d1bae3f3b214cbf08cadbc4 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpRequest.h,v 1.22 2006/05/08 23:38:33 robertc Exp $
+ * $Id: HttpRequest.h,v 1.23 2006/05/29 21:44:18 robertc Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -66,6 +66,9 @@ public:
 
     void initHTTP(method_t aMethod, protocol_t aProtocol, const char *aUrlpath);
 
+    /* are responses to this request potentially cachable */
+    bool cacheable() const;
+
 protected:
     void clean();
 
index e90cf676a2d7d5012202cf57d9a7a7a1d3a838e3..7a8f990e34b6e159d4e8835420642421098c9b7f 100644 (file)
@@ -1,7 +1,7 @@
 #
 #  Makefile for the Squid Object Cache server
 #
-#  $Id: Makefile.am,v 1.148 2006/05/29 00:15:00 robertc Exp $
+#  $Id: Makefile.am,v 1.149 2006/05/29 21:44:18 robertc Exp $
 #
 #  Uncomment and customize the following to suit your needs:
 #
@@ -1309,6 +1309,7 @@ tests_testCacheManager_LDADD = \
        @SSLLIB@ \
        -L../lib -lmiscutil \
        @XTRA_LIBS@ \
+       @SQUID_CPPUNIT_LIBS@ \
        @SQUID_CPPUNIT_LA@ \
        @SNMPLIB@ 
 tests_testCacheManager_LDFLAGS = $(LIBADD_DL)
@@ -1764,7 +1765,7 @@ SWAP_TEST_LDADD = \
        @REPL_OBJS@ \
        @DISK_LIBS@ \
        -L../lib -lmiscutil \
-       @SQUID_CPPUNITLIBS@
+       @SQUID_CPPUNIT_LIBS@
 SWAP_TEST_DS =\
        $(top_builddir)/lib/libmiscutil.a \
        DiskIO/Blocking/BlockingDiskIOModule.o \
index 937bc18c83e288c11506b0c24bbc9df199f2ef29..150be600ec1cd8b5b8c631968a42bb44ac145484 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side_request.cc,v 1.68 2006/05/19 17:19:09 wessels Exp $
+ * $Id: client_side_request.cc,v 1.69 2006/05/29 21:44:18 robertc Exp $
  * 
  * DEBUG: section 85    Client-side Request Routines
  * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c)
@@ -92,7 +92,6 @@ ClientRequestContext::operator delete (void *address)
 /* Local functions */
 /* other */
 static void clientAccessCheckDoneWrapper(int, void *);
-static int clientCachable(ClientHttpRequest * http);
 static int clientHierarchical(ClientHttpRequest * http);
 static void clientInterpretRequestHeaders(ClientHttpRequest * http);
 static RH clientRedirectDoneWrapper;
@@ -562,47 +561,6 @@ ClientRequestContext::clientRedirectStart()
         redirectStart(http, clientRedirectDoneWrapper, this);
 }
 
-static int
-clientCachable(ClientHttpRequest * http)
-{
-    HttpRequest *req = http->request;
-    method_t method = req->method;
-
-    if (req->protocol == PROTO_HTTP)
-        return httpCachable(method);
-
-    /* FTP is always cachable */
-    if (req->protocol == PROTO_WAIS)
-        return 0;
-
-    /*
-     * The below looks questionable: what non HTTP protocols use connect,
-     * trace, put and post? RC
-     */
-    if (method == METHOD_CONNECT)
-        return 0;
-
-    if (method == METHOD_TRACE)
-        return 0;
-
-    if (method == METHOD_PUT)
-        return 0;
-
-    if (method == METHOD_POST)
-        return 0;
-
-    /* XXX POST may be cached sometimes.. ignored
-                        
-                                                                * for now */
-    if (req->protocol == PROTO_GOPHER)
-        return gopherCachable(req);
-
-    if (req->protocol == PROTO_CACHEOBJ)
-        return 0;
-
-    return 1;
-}
-
 static int
 clientHierarchical(ClientHttpRequest * http)
 {
@@ -801,8 +759,7 @@ clientInterpretRequestHeaders(ClientHttpRequest * http)
         request->max_forwards = req_hdr->getInt(HDR_MAX_FORWARDS);
     }
 
-    if (clientCachable(http))
-        request->flags.cachable = 1;
+    request->flags.cachable = http->request->cacheable();
 
     if (clientHierarchical(http))
         request->flags.hierarchical = 1;
index 81f9abd66fcf4e51c3c3511a1120f3bb15e3ca9e..fe030dc3a05240cc0223577551f768d06bb37512 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm_epoll.cc,v 1.10 2006/05/29 00:15:01 robertc Exp $
+ * $Id: comm_epoll.cc,v 1.11 2006/05/29 21:44:18 robertc Exp $
  *
  * DEBUG: section 5    Socket functions
  *
@@ -194,14 +194,31 @@ commSetSelect(int fd, unsigned int type, PF * handler,
         F->timeout = squid_curtime + timeout;
 }
 
+
+static void commIncomingStats(StoreEntry * sentry);
+
+void
+commEPollRegisterWithCacheManager(CacheManager& manager)
+{
+    manager.registerAction("comm_epoll_incoming",
+                           "comm_incoming() stats",
+                           commIncomingStats, 0, 1);
+}
+
+static void
+commIncomingStats(StoreEntry * sentry)
+{
+    StatCounters *f = &statCounter;
+    storeAppendPrintf(sentry, "Total number of epoll(2) loops: %d\n", statCounter.select_loops);
+    storeAppendPrintf(sentry, "Histogram of returned filedescriptors\n");
+    statHistDump(&f->select_fds_hist, sentry, statHistIntDumper);
+}
+
 /*
+ * comm_select
  * Check all connections for new connections and input data that is to be
  * processed. Also check for connections with data queued and whether we can
  * write it out.
- */
-
-/*
- * comm_select
  *
  * Called to do the new-style IO, courtesy of of squid (like most of this
  * new IO code). This routine handles the stuff we've hidden in
index 23e052f96a6808a3118b1308c117670e9b234e1f..947902f2154e748eeb4ff0a8101e87c0b9ce9f06 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: main.cc,v 1.423 2006/05/29 00:15:02 robertc Exp $
+ * $Id: main.cc,v 1.424 2006/05/29 21:44:18 robertc Exp $
  *
  * DEBUG: section 1     Startup and Main Loop
  * AUTHOR: Harvest Derived
@@ -867,7 +867,11 @@ mainInitialize(void)
 #endif
 
         clientdbRegisterWithCacheManager(manager);
+#if DELAY_POOLS
+
         DelayPools::RegisterWithCacheManager(manager);
+#endif
+
         DiskIOModule::RegisterAllModulesWithCacheManager(manager);
 #if USE_DNSSERVERS
 
@@ -895,7 +899,11 @@ mainInitialize(void)
         StringRegistry::Instance().registerWithCacheManager(manager);
 #endif
 
+#if    USE_XPROF_STATS
+
         xprofRegisterWithCacheManager(manager);
+#endif
+
     }
 
 #if USE_WCCP
index 6a2faa487557f0e4ff54891b8f1bd09ba1e6234f..d10d93240b4b4cd04d2fe1fc84d43144c44d7f3a 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_digest.cc,v 1.67 2006/05/29 00:15:02 robertc Exp $
+ * $Id: store_digest.cc,v 1.68 2006/05/29 21:44:18 robertc Exp $
  *
  * DEBUG: section 71    Store Digest Manager
  * AUTHOR: Alex Rousskov
@@ -41,9 +41,9 @@
  */
 
 #include "squid.h"
+#include "CacheManager.h"
 #if USE_CACHE_DIGESTS
 
-#include "CacheManager.h"
 #include "Store.h"
 #include "HttpRequest.h"
 #include "HttpReply.h"
index c57ce05c121794504ae071db52ab86ec65df381f..b50c867ba726d4f373e6cc504360c88de4119add 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: url.cc,v 1.154 2006/05/08 23:38:33 robertc Exp $
+ * $Id: url.cc,v 1.155 2006/05/29 21:44:18 robertc Exp $
  *
  * DEBUG: section 23    URL Parsing
  * AUTHOR: Duane Wessels
@@ -569,13 +569,22 @@ matchDomainName(const char *h, const char *d)
 
 
 /*
- * what does the return code of this mean ?
+ * return true if we can serve requests for this method.
  */
 int
 urlCheckRequest(const HttpRequest * r)
 {
     int rc = 0;
-    /* protocol "independent" methods */
+    /* protocol "independent" methods
+     *
+     * actually these methods are specific to HTTP:
+     * they are methods we recieve on our HTTP port,
+     * and if we had a FTP listener would not be relevant
+     * there.
+     *
+     * So, we should delegate them to HTTP. The problem is that we
+     * do not have a default protocol from the client side of HTTP.
+     */
 
     if (r->method == METHOD_CONNECT)
         return 1;