From: Benno Rice Date: Mon, 1 Sep 2008 05:27:59 +0000 (+1000) Subject: More checkpoint. X-Git-Tag: SQUID_3_1_0_1~49^2~9^2~10^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=90bd689cdbc92de0c58af7091b9cbb548d0d25ec;p=thirdparty%2Fsquid.git More checkpoint. --- diff --git a/src/Server.cc b/src/Server.cc index 2ec77c2efd..8ad9d887d5 100644 --- a/src/Server.cc +++ b/src/Server.cc @@ -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); } diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index a971611989..c18b9e55c6 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -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 diff --git a/src/enums.h b/src/enums.h index ed4e5f135b..5ab13f8c7c 100644 --- a/src/enums.h +++ b/src/enums.h @@ -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 */ diff --git a/src/htcp.cc b/src/htcp.cc index e52d1c6a14..a8c27ef9e9 100644 --- a/src/htcp.cc +++ b/src/htcp.cc @@ -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)) { diff --git a/src/htcp.h b/src/htcp.h index 2149aa5d67..ce88858288 100644 --- a/src/htcp.h +++ b/src/htcp.h @@ -37,11 +37,6 @@ #include "HttpHeader.h" #include "IPAddress.h" -typedef enum { - HTCP_CLR_PURGE, - HTCP_CLR_INVALIDATION, -} htcp_clr_reason; - /// \ingroup ServerProtocolHTCP class HtcpReplyData { diff --git a/src/neighbors.cc b/src/neighbors.cc index 6b3b2658c5..9c73dec59c 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -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); } } diff --git a/src/protos.h b/src/protos.h index 9cc88fd3e4..193dabe31b 100644 --- a/src/protos.h +++ b/src/protos.h @@ -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);