From: robertc <> Date: Tue, 30 May 2006 03:44:18 +0000 (+0000) Subject: Move clientCachable logic onto HttpRequest, as all the used fields in the X-Git-Tag: SQUID_3_0_PRE4~77 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=610ee3419c0f2cbb80e33ebfdd5d0eb5cb6995eb;p=thirdparty%2Fsquid.git Move clientCachable logic onto HttpRequest, as all the used fields in the function where on the HttpRequest object. Apply Gonzalo Aranas bugfix for the replacement to cachemgrRegister, as having some options disabled/changed did not compile. --- diff --git a/src/HttpRequest.cc b/src/HttpRequest.cc index f2106aa1fc..afa7703236 100644 --- a/src/HttpRequest.cc +++ b/src/HttpRequest.cc @@ -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; +} diff --git a/src/HttpRequest.h b/src/HttpRequest.h index 6add8ee3d3..7327fdd294 100644 --- a/src/HttpRequest.h +++ b/src/HttpRequest.h @@ -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(); diff --git a/src/Makefile.am b/src/Makefile.am index e90cf676a2..7a8f990e34 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 \ diff --git a/src/client_side_request.cc b/src/client_side_request.cc index 937bc18c83..150be600ec 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -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; diff --git a/src/comm_epoll.cc b/src/comm_epoll.cc index 81f9abd66f..fe030dc3a0 100644 --- a/src/comm_epoll.cc +++ b/src/comm_epoll.cc @@ -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 diff --git a/src/main.cc b/src/main.cc index 23e052f96a..947902f215 100644 --- a/src/main.cc +++ b/src/main.cc @@ -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 diff --git a/src/store_digest.cc b/src/store_digest.cc index 6a2faa4875..d10d93240b 100644 --- a/src/store_digest.cc +++ b/src/store_digest.cc @@ -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" diff --git a/src/url.cc b/src/url.cc index c57ce05c12..b50c867ba7 100644 --- a/src/url.cc +++ b/src/url.cc @@ -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;