]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
More checkpoint.
authorBenno Rice <benno@squid-cache.org>
Mon, 1 Sep 2008 05:27:59 +0000 (15:27 +1000)
committerBenno Rice <benno@squid-cache.org>
Mon, 1 Sep 2008 05:27:59 +0000 (15:27 +1000)
src/Server.cc
src/client_side_reply.cc
src/enums.h
src/htcp.cc
src/htcp.h
src/neighbors.cc
src/protos.h

index 2ec77c2efdf4af5c3d6705e45f67e087d562118c..8ad9d887d51b4ba5b4e02822e5ff13ae4cb807f8 100644 (file)
@@ -46,7 +46,7 @@
 #endif
 
 // implemented in client_side_reply.cc until sides have a common parent
-extern void purgeEntriesByUrl(const char *url);
+extern void purgeEntriesByUrl(HttpRequest * req, const char *url);
 
 
 ServerStateData::ServerStateData(FwdState *theFwdState): AsyncJob("ServerStateData"),requestSender(NULL)
@@ -402,7 +402,7 @@ sameUrlHosts(const char *url1, const char *url2)
 
 // purges entries that match the value of a given HTTP [response] header
 static void
-purgeEntriesByHeader(const HttpRequest *req, const char *reqUrl, HttpMsg *rep, http_hdr_type hdr)
+purgeEntriesByHeader(HttpRequest *req, const char *reqUrl, HttpMsg *rep, http_hdr_type hdr)
 {
     const char *url, *absUrl;
     
@@ -412,9 +412,9 @@ purgeEntriesByHeader(const HttpRequest *req, const char *reqUrl, HttpMsg *rep, h
                url = absUrl;
            }
            if (absUrl != NULL) { // if the URL was relative, it is by nature the same host
-            purgeEntriesByUrl(url);
+            purgeEntriesByUrl(req, url);
            } else if (sameUrlHosts(reqUrl, url)) { // prevent purging DoS, per RFC 2616 13.10, second last paragraph
-            purgeEntriesByUrl(url);
+            purgeEntriesByUrl(req, url);
         }
         if (absUrl != NULL) {
             safe_free(absUrl);
@@ -437,7 +437,7 @@ ServerStateData::maybePurgeOthers()
    // XXX: should we use originalRequest() here?
    const char *reqUrl = urlCanonical(request);
    debugs(88, 5, "maybe purging due to " << RequestMethodStr(request->method) << ' ' << reqUrl);
-   purgeEntriesByUrl(reqUrl);
+   purgeEntriesByUrl(request, reqUrl);
    purgeEntriesByHeader(request, reqUrl, theFinalReply, HDR_LOCATION);
    purgeEntriesByHeader(request, reqUrl, theFinalReply, HDR_CONTENT_LOCATION);
 }
index a971611989ce9138d7dd288a0ff12e0995d13553..c18b9e55c616d56a9af901fb2c844965325d7d70 100644 (file)
@@ -721,13 +721,16 @@ clientReplyContext::purgeRequestFindObjectToPurge()
  * keys depend on vary headers.
  */
 void
-purgeEntriesByUrl(const char *url)
+purgeEntriesByUrl(HttpRequest * req, const char *url)
 {
     for (HttpRequestMethod m(METHOD_NONE); m != METHOD_ENUM_END; ++m) {
         if (m.isCacheble()) {
             if (StoreEntry *entry = storeGetPublic(url, m)) {
                 debugs(88, 5, "purging " << RequestMethodStr(m) << ' ' << url);
                 entry->release();
+#if USE_HTCP
+                neighborsHtcpClear(NULL, url, req, &m, HTCP_CLR_INVALIDATION);
+#endif
             }
         }
     }
@@ -737,7 +740,7 @@ void
 clientReplyContext::purgeAllCached()
 {
        const char *url = urlCanonical(http->request);
-    purgeEntriesByUrl(url);
+    purgeEntriesByUrl(http->request, url);
 }
 
 void
index ed4e5f135b0d18637c85e0d521021cc9c2d9e622..5ab13f8c7c6f1fdee27897b9be08e229cfe61115 100644 (file)
@@ -545,4 +545,15 @@ enum {
     DISABLE_PMTU_TRANSPARENT
 };
 
+#if USE_HTCP
+/*
+ * This should be in htcp.h but because neighborsHtcpClear is defined in
+ * protos.h it has to be here.
+ */
+typedef enum {
+    HTCP_CLR_PURGE,
+    HTCP_CLR_INVALIDATION,
+} htcp_clr_reason;
+#endif
+
 #endif /* SQUID_ENUMS_H */
index e52d1c6a14db7580c0c74b45704ea084eadfd631..a8c27ef9e9a89b8facc2fd7ab54978c0b6632d4a 100644 (file)
@@ -1311,7 +1311,7 @@ htcpForwardClr(char *buf, int sz)
 {
     peer *p;
     
-    for (p = Config.peers; p; p->next) {
+    for (p = Config.peers; p; p = p->next) {
         if (!p->options.htcp) {
             continue;
         }
@@ -1324,14 +1324,6 @@ htcpForwardClr(char *buf, int sz)
 }
 
 static void
-
-htcpHandleData(char *buf, int sz, IPAddress &from)
-{
-
-}
-
-static void
-
 htcpHandle(char *buf, int sz, IPAddress &from)
 {
     htcpHeader htcpHdr;
@@ -1374,8 +1366,8 @@ htcpHandle(char *buf, int sz, IPAddress &from)
         return;
     }
 
-    hbuf += sizeof(htcpHeader);
-    hsz -= sizeof(htcpHeader);
+    hbuf = buf + sizeof(htcpHeader);
+    hsz = sz - sizeof(htcpHeader);
 
     if ((size_t)hsz < sizeof(htcpDataHeader))
     {
index 2149aa5d67b3efa413596bc1ab26d957eb5c96cb..ce8885828802281b5dbcef34328a9462914be839 100644 (file)
 #include "HttpHeader.h"
 #include "IPAddress.h"
 
-typedef enum {
-    HTCP_CLR_PURGE,
-    HTCP_CLR_INVALIDATION,
-} htcp_clr_reason;
-
 /// \ingroup ServerProtocolHTCP
 class HtcpReplyData
 {
index 6b3b2658c59168b91c1d33bebf69fa898e6eb458..9c73dec59cc1a5c2d40163037de64ef4ea0929e1 100644 (file)
@@ -1840,7 +1840,7 @@ neighborsHtcpClear(StoreEntry * e, const char *uri, HttpRequest * req, HttpReque
         if (p->options.htcp_no_purge_clr && reason == HTCP_CLR_PURGE) {
             continue;
         }
-        debug(15, 1) ("neighborsHtcpClear: sending CLR to %s\n", p->in_addr->ToURL(buf, 128););
+        debug(15, 1) ("neighborsHtcpClear: sending CLR to %s\n", p->in_addr.ToURL(buf, 128));
         htcpClear(e, uri, req, method, p, reason);
     }
 }
index 9cc88fd3e49ca55466de9ca6b9d293b95804b76a..193dabe31baa0de60ae5239eea5e1cbe5ca22028 100644 (file)
@@ -387,6 +387,7 @@ SQUIDCEXTERN void neighborAdd(const char *, const char *, int, int, int, int, in
 SQUIDCEXTERN void neighbors_init(void);
 #if USE_HTCP
 SQUIDCEXTERN void neighborsHtcpClear(StoreEntry *, const char *, HttpRequest *, HttpRequestMethod *, htcp_clr_reason);
+#endif
 SQUIDCEXTERN peer *peerFindByName(const char *);
 SQUIDCEXTERN peer *peerFindByNameAndPort(const char *, unsigned short);
 SQUIDCEXTERN peer *getDefaultParent(HttpRequest * request);