- Fix purgeEntriesByUrl call.
- Add logic needed to send HTCP CLR request.
- Add logic needed to send HTCP CLR requests to all configured neighbors.
- Wire in calls to send CLR requests to neighbors in appropriate places.
- Use a reference to the HttpRequestMethod rather than a pointer.
- Various cleanups.
return;
}
- purgeEntriesByUrl(hdrUrl);
+ purgeEntriesByUrl(req, hdrUrl);
if (absUrl != NULL) {
safe_free(absUrl);
void
purgeEntriesByUrl(HttpRequest * req, const char *url)
{
+#if USE_HTCP
+ bool get_or_head_sent = false;
+#endif
+
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);
+ neighborsHtcpClear(entry, url, req, m, HTCP_CLR_INVALIDATION);
+ if (m == METHOD_GET || m == METHOD_HEAD) {
+ get_or_head_sent = true;
+ }
#endif
+ entry->release();
}
}
}
+
+#if USE_HTCP
+ if (!get_or_head_sent) {
+ neighborsHtcpClear(NULL, url, req, HttpRequestMethod(METHOD_GET), HTCP_CLR_INVALIDATION);
+ }
+#endif
}
void
if (!newEntry->isNull()) {
/* Release the cached URI */
debugs(88, 4, "clientPurgeRequest: GET '" << newEntry->url() << "'" );
+#if USE_HTCP
+ neighborsHtcpClear(newEntry, NULL, http->request, HttpRequestMethod(METHOD_GET), HTCP_CLR_PURGE);
+#endif
newEntry->release();
purgeStatus = HTTP_OK;
}
{
if (newEntry && !newEntry->isNull()) {
debugs(88, 4, "clientPurgeRequest: HEAD '" << newEntry->url() << "'" );
+#if USE_HTCP
+ neighborsHtcpClear(newEntry, NULL, http->request, HttpRequestMethod(METHOD_HEAD), HTCP_CLR_PURGE);
+#endif
newEntry->release();
purgeStatus = HTTP_OK;
}
if (entry) {
debugs(88, 4, "clientPurgeRequest: Vary GET '" << entry->url() << "'" );
+#if USE_HTCP
+ neighborsHtcpClear(entry, NULL, http->request, HttpRequestMethod(METHOD_GET), HTCP_CLR_PURGE);
+#endif
entry->release();
purgeStatus = HTTP_OK;
}
if (entry) {
debugs(88, 4, "clientPurgeRequest: Vary HEAD '" << entry->url() << "'" );
+#if USE_HTCP
+ neighborsHtcpClear(entry, NULL, http->request, HttpRequestMethod(METHOD_HEAD), HTCP_CLR_PURGE);
+#endif
entry->release();
purgeStatus = HTTP_OK;
}
}
void
-htcpClear(StoreEntry * e, const char *uri, HttpRequest * req, HttpRequestMethod * method, peer * p, htcp_clr_reason reason)
+htcpClear(StoreEntry * e, const char *uri, HttpRequest * req, const HttpRequestMethod &method, peer * p, htcp_clr_reason reason)
{
static char pkt[8192];
ssize_t pktlen;
hdr.clean();
packerClean(&pa);
stuff.S.req_hdrs = mb.buf;
+ debug(31, 1) ("htcpClear: headers: %s\n", stuff.S.req_hdrs);
+ } else {
+ stuff.S.req_hdrs = NULL;
}
pktlen = htcpBuildPacket(pkt, sizeof(pkt), &stuff);
if (reason != HTCP_CLR_INVALIDATION) {
xfree(stuff.S.uri);
}
if (!pktlen) {
- debug(31, 1) ("htcpQuery: htcpBuildPacket() failed\n");
+ debug(31, 1) ("htcpClear: htcpBuildPacket() failed\n");
return;
}
SQUIDCEXTERN void htcpQuery(StoreEntry * e, HttpRequest * req, peer * p);
/// \ingroup ServerProtocolHTCP
-SQUIDCEXTERN void htcpClear(StoreEntry * e, const char *uri, HttpRequest * req, HttpRequestMethod * method, peer * p, htcp_clr_reason reason);
+SQUIDCEXTERN void htcpClear(StoreEntry * e, const char *uri, HttpRequest * req, const HttpRequestMethod &method, peer * p, htcp_clr_reason reason);
/// \ingroup ServerProtocolHTCP
SQUIDCEXTERN void htcpSocketShutdown(void);
if (pe != NULL) {
assert(e != pe);
#if USE_HTCP
- neighborsHtcpClear(e, NULL, e->mem_obj->request, &e->mem_obj->method, HTCP_CLR_INVALIDATION);
+ neighborsHtcpClear(e, NULL, e->mem_obj->request, e->mem_obj->method, HTCP_CLR_INVALIDATION);
#endif
pe->release();
}
if (pe != NULL) {
assert(e != pe);
#if USE_HTCP
- HttpRequestMethod headMethod(METHOD_HEAD);
- neighborsHtcpClear(e, NULL, e->mem_obj->request, &headMethod, HTCP_CLR_INVALIDATION);
+ neighborsHtcpClear(e, NULL, e->mem_obj->request, HttpRequestMethod(METHOD_HEAD), HTCP_CLR_INVALIDATION);
#endif
pe->release();
}
}
void
-neighborsHtcpClear(StoreEntry * e, const char *uri, HttpRequest * req, HttpRequestMethod * method, htcp_clr_reason reason)
+neighborsHtcpClear(StoreEntry * e, const char *uri, HttpRequest * req, const HttpRequestMethod &method, htcp_clr_reason reason)
{
peer *p;
char buf[128];
SQUIDCEXTERN void neighborAdd(const char *, const char *, int, int, int, int, int);
SQUIDCEXTERN void neighbors_init(void);
#if USE_HTCP
-SQUIDCEXTERN void neighborsHtcpClear(StoreEntry *, const char *, HttpRequest *, HttpRequestMethod *, htcp_clr_reason);
+SQUIDCEXTERN void neighborsHtcpClear(StoreEntry *, const char *, HttpRequest *, const HttpRequestMethod &, htcp_clr_reason);
#endif
SQUIDCEXTERN peer *peerFindByName(const char *);
SQUIDCEXTERN peer *peerFindByNameAndPort(const char *, unsigned short);