--------------------- PatchSet 11741 Date: 2007/11/16 11:38:46 Author: adrian Branch: HEAD Tag: (none) Log: Modifications to use a split store_url and url in the lookup/storage path. Members: src/client_side.c:1.744->1.745 src/client_side_storeurl_rewrite.c:1.2->1.3 src/enums.h:1.240->1.241 src/protos.h:1.541->1.542 src/store.c:1.580->1.581 src/store_client.c:1.124->1.125 src/store_key_md5.c:1.30->1.31 src/store_swapmeta.c:1.21->1.22 src/structs.h:1.530->1.531 Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid/squid/src/client_side.c,v retrieving revision 1.744 retrieving revision 1.745 diff -u -r1.744 -r1.745 --- squid/src/client_side.c 15 Nov 2007 04:43:55 -0000 1.744 +++ squid/src/client_side.c 16 Nov 2007 11:38:46 -0000 1.745 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.744 2007/11/15 04:43:55 adrian Exp $ + * $Id: client_side.c,v 1.745 2007/11/16 11:38:46 adrian Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -416,6 +416,8 @@ if (h->request == NULL) h->request = requestLink(requestCreate(m, PROTO_NONE, null_string)); e = storeCreateEntry(h->uri, flags, m); + if (h->request->store_url) + storeEntrySetStoreUrl(e, h->request->store_url); h->sc = storeClientRegister(e, h); #if DELAY_POOLS if (h->log_type != LOG_TCP_DENIED) @@ -598,7 +600,7 @@ { clientHttpRequest *http = data; StoreEntry *entry = http->entry; - const char *url = storeUrl(entry); + const char *url = storeLookupUrl(entry); if (entry == NULL) { /* client aborted */ return; @@ -646,6 +648,8 @@ StoreEntry *entry = NULL; debug(33, 3) ("clientProcessETag: '%s'\n", http->uri); entry = storeCreateEntry(url, http->request->flags, http->request->method); + if (http->request->store_url) + storeEntrySetStoreUrl(entry, http->request->store_url); http->sc = storeClientRegister(entry, http); #if DELAY_POOLS /* delay_id is already set on original store client */ @@ -703,6 +707,8 @@ } if (!entry) { entry = storeCreateEntry(url, http->request->flags, http->request->method); + if (http->request->store_url) + storeEntrySetStoreUrl(entry, http->request->store_url); if (http->entry->mem_obj) { http->entry->mem_obj->refresh_timestamp = squid_curtime; if (Config.onoff.collapsed_forwarding) { @@ -889,7 +895,7 @@ squid_off_t object_length; MemObject *mem = entry->mem_obj; time_t mod_time = entry->lastmod; - debug(33, 3) ("modifiedSince: '%s'\n", storeUrl(entry)); + debug(33, 3) ("modifiedSince: '%s'\n", storeLookupUrl(entry)); debug(33, 3) ("modifiedSince: mod_time = %ld\n", (long int) mod_time); if (mod_time < 0) return 1; @@ -1972,7 +1978,16 @@ mem = e->mem_obj; debug(33, 3) ("clientCacheHit: %s = %d\n", http->uri, rep->sline.status); assert(!EBIT_TEST(e->flags, ENTRY_ABORTED)); - if (strcmp(mem->url, urlCanonical(r)) != 0) { + + if (r->store_url && mem->store_url == NULL) { + debug(33, 1) ("clientCacheHit: request has store_url '%s'; mem object in hit doesn't!\n", r->store_url); + clientProcessMiss(http); + return; + } else if (r->store_url && strcmp(mem->store_url, r->store_url) != 0) { + debug(33, 1) ("clientCacheHit: store URL mismatch '%s' != '%s'?\n", mem->store_url, r->store_url); + clientProcessMiss(http); + return; + } else if (strcmp(mem->url, urlCanonical(r)) != 0) { debug(33, 1) ("clientCacheHit: URL mismatch '%s' != '%s'?\n", e->mem_obj->url, urlCanonical(r)); clientProcessMiss(http); return; Index: squid/src/client_side_storeurl_rewrite.c =================================================================== RCS file: /cvsroot/squid/squid/src/client_side_storeurl_rewrite.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- squid/src/client_side_storeurl_rewrite.c 15 Nov 2007 05:37:18 -0000 1.2 +++ squid/src/client_side_storeurl_rewrite.c 16 Nov 2007 11:38:46 -0000 1.3 @@ -1,8 +1,8 @@ /* - * $Id: client_side_storeurl_rewrite.c,v 1.2 2007/11/15 05:37:18 adrian Exp $ + * $Id: client_side_storeurl_rewrite.c,v 1.3 2007/11/16 11:38:46 adrian Exp $ * - * DEBUG: section 33 Client-side Routines - Store URL Rewriter + * DEBUG: section 85 Client-side Routines - Store URL Rewriter * AUTHOR: Duane Wessels; Adrian Chadd * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -52,7 +52,7 @@ void clientStoreURLRewriteStart(clientHttpRequest * http) { - debug(33, 5) ("clientStoreURLRewriteStart: '%s'\n", http->uri); + debug(85, 5) ("clientStoreURLRewriteStart: '%s'\n", http->uri); if (Config.Program.store_rewrite.command == NULL) { clientStoreURLRewriteDone(http, NULL); return; @@ -70,7 +70,7 @@ { clientHttpRequest *http = data; - debug(33, 3) ("clientStoreURLRewriteDone: '%s' result=%s\n", http->uri, + debug(85, 3) ("clientStoreURLRewriteDone: '%s' result=%s\n", http->uri, result ? result : "NULL"); #if 0 assert(http->redirect_state == REDIRECT_PENDING); @@ -78,6 +78,10 @@ #endif if (result) { + http->request->store_url = xstrdup(result); + debug(85, 3) ("Rewrote to %s\n", http->request->store_url); + /* XXX is this actually the right spot to do this? How about revalidation? */ + //storeEntrySetStoreUrl(http->entry, result); } /* This is the final part of the rewrite chain - this should be broken out! */ clientInterpretRequestHeaders(http); Index: squid/src/enums.h =================================================================== RCS file: /cvsroot/squid/squid/src/enums.h,v retrieving revision 1.240 retrieving revision 1.241 diff -u -r1.240 -r1.241 --- squid/src/enums.h 24 Sep 2007 13:31:19 -0000 1.240 +++ squid/src/enums.h 16 Nov 2007 11:38:46 -0000 1.241 @@ -1,6 +1,6 @@ /* - * $Id: enums.h,v 1.240 2007/09/24 13:31:19 hno Exp $ + * $Id: enums.h,v 1.241 2007/11/16 11:38:46 adrian Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -654,6 +654,7 @@ STORE_META_VARY_HEADERS, /* Stores Vary request headers */ STORE_META_STD_LFS, /* standard metadata in lfs format */ STORE_META_OBJSIZE, /* object size, if its known */ + STORE_META_STOREURL, /* the store url, if different to the normal URL */ STORE_META_END }; Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid/squid/src/protos.h,v retrieving revision 1.541 retrieving revision 1.542 diff -u -r1.541 -r1.542 --- squid/src/protos.h 15 Nov 2007 05:37:18 -0000 1.541 +++ squid/src/protos.h 16 Nov 2007 11:38:46 -0000 1.542 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.541 2007/11/15 05:37:18 adrian Exp $ + * $Id: protos.h,v 1.542 2007/11/16 11:38:46 adrian Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -908,6 +908,7 @@ * store.c */ extern StoreEntry *new_StoreEntry(int, const char *); +extern void storeEntrySetStoreUrl(StoreEntry * e, const char *store_url); extern StoreEntry *storeGet(const cache_key *); extern StoreEntry *storeGetPublic(const char *uri, const method_t method); extern StoreEntry *storeGetPublicByRequest(request_t * request); @@ -921,6 +922,7 @@ extern void storeLockObjectDebug(StoreEntry *, const char *file, const int line); extern void storeRelease(StoreEntry *); extern int storeUnlockObjectDebug(StoreEntry *, const char *file, const int line); +extern const char *storeLookupUrl(const StoreEntry * e); #define storeLockObject(a) storeLockObjectDebug(a, __FILE__, __LINE__); #define storeUnlockObject(a) storeUnlockObjectDebug(a, __FILE__, __LINE__); extern EVH storeMaintainSwapSpace; Index: squid/src/store.c =================================================================== RCS file: /cvsroot/squid/squid/src/store.c,v retrieving revision 1.580 retrieving revision 1.581 diff -u -r1.580 -r1.581 --- squid/src/store.c 25 Sep 2007 00:51:55 -0000 1.580 +++ squid/src/store.c 16 Nov 2007 11:38:46 -0000 1.581 @@ -1,6 +1,6 @@ /* - * $Id: store.c,v 1.580 2007/09/25 00:51:55 hno Exp $ + * $Id: store.c,v 1.581 2007/11/16 11:38:46 adrian Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -152,6 +152,16 @@ return e; } +void +storeEntrySetStoreUrl(StoreEntry * e, const char *store_url) +{ + /* XXX eww, another strdup! */ + if (!e->mem_obj) + return; + safe_free(e->mem_obj->store_url); + e->mem_obj->store_url = xstrdup(store_url); +} + static void destroy_MemObject(StoreEntry * e) { @@ -1012,7 +1022,7 @@ * to record the new variance key */ safe_free(request->vary_headers); /* free old "bad" variance key */ - pe = storeGetPublic(mem->url, mem->method); + pe = storeGetPublic(storeLookupUrl(e), mem->method); if (pe) storeRelease(pe); } @@ -1044,7 +1054,7 @@ stringClean(&vary); } } else { - newkey = storeKeyPublic(mem->url, mem->method); + newkey = storeKeyPublic(storeLookupUrl(e), mem->method); } if ((e2 = (StoreEntry *) hash_lookup(store_table, newkey))) { debug(20, 3) ("storeSetPublicKey: Making old '%s' private.\n", mem->url); @@ -1053,7 +1063,7 @@ if (mem->request) newkey = storeKeyPublicByRequest(mem->request); else - newkey = storeKeyPublic(mem->url, mem->method); + newkey = storeKeyPublic(storeLookupUrl(e), mem->method); } if (e->hash.key) storeHashDelete(e); @@ -1821,6 +1831,19 @@ return e->mem_obj->url; } +const char * +storeLookupUrl(const StoreEntry * e) +{ + if (e == NULL) + return "[null_entry]"; + else if (e->mem_obj == NULL) + return "[null_mem_obj]"; + else if (e->mem_obj->store_url) + return e->mem_obj->store_url; + else + return e->mem_obj->url; +} + void storeCreateMemObject(StoreEntry * e, const char *url) { Index: squid/src/store_client.c =================================================================== RCS file: /cvsroot/squid/squid/src/store_client.c,v retrieving revision 1.124 retrieving revision 1.125 diff -u -r1.124 -r1.125 --- squid/src/store_client.c 26 Jan 2007 02:33:12 -0000 1.124 +++ squid/src/store_client.c 16 Nov 2007 11:38:46 -0000 1.125 @@ -1,6 +1,6 @@ /* - * $Id: store_client.c,v 1.124 2007/01/26 02:33:12 adrian Exp $ + * $Id: store_client.c,v 1.125 2007/11/16 11:38:46 adrian Exp $ * * DEBUG: section 20 Storage Manager Client-Side Interface * AUTHOR: Duane Wessels @@ -432,6 +432,18 @@ break; } break; + case STORE_META_STOREURL: + if (NULL == mem->store_url) + mem->store_url = xstrdup(t->value); + else if (0 == strcasecmp(mem->store_url, t->value)) + (void) 0; /* a match! */ + else { + debug(20, 1) ("storeClientReadHeader: store URL mismatch\n"); + debug(20, 1) ("\t{%s} != {%s}\n", (char *) t->value, mem->store_url); + swap_object_ok = 0; + break; + } + break; case STORE_META_OBJSIZE: break; case STORE_META_STD: Index: squid/src/store_key_md5.c =================================================================== RCS file: /cvsroot/squid/squid/src/store_key_md5.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- squid/src/store_key_md5.c 21 Jan 2007 12:54:00 -0000 1.30 +++ squid/src/store_key_md5.c 16 Nov 2007 11:38:46 -0000 1.31 @@ -1,6 +1,6 @@ /* - * $Id: store_key_md5.c,v 1.30 2007/01/21 12:54:00 adrian Exp $ + * $Id: store_key_md5.c,v 1.31 2007/11/16 11:38:46 adrian Exp $ * * DEBUG: section 20 Storage Manager MD5 Cache Keys * AUTHOR: Duane Wessels @@ -131,7 +131,14 @@ { static cache_key digest[MD5_DIGEST_CHARS]; unsigned char m = (unsigned char) method; - const char *url = urlCanonical(request); + const char *url; + + if (request->store_url) { + url = request->store_url; + } else { + url = urlCanonical(request); + } + MD5_CTX M; MD5Init(&M); MD5Update(&M, &m, sizeof(m)); Index: squid/src/store_swapmeta.c =================================================================== RCS file: /cvsroot/squid/squid/src/store_swapmeta.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- squid/src/store_swapmeta.c 29 Jul 2006 14:44:49 -0000 1.21 +++ squid/src/store_swapmeta.c 16 Nov 2007 11:38:46 -0000 1.22 @@ -1,6 +1,6 @@ /* - * $Id: store_swapmeta.c,v 1.21 2006/07/29 14:44:49 hno Exp $ + * $Id: store_swapmeta.c,v 1.22 2007/11/16 11:38:46 adrian Exp $ * * DEBUG: section 20 Storage Manager Swapfile Metadata * AUTHOR: Kostas Anagnostakis @@ -86,6 +86,8 @@ vary = e->mem_obj->vary_headers; if (vary) T = storeSwapTLVAdd(STORE_META_VARY_HEADERS, vary, strlen(vary) + 1, T); + if (e->mem_obj->store_url) + T = storeSwapTLVAdd(STORE_META_STOREURL, e->mem_obj->store_url, strlen(e->mem_obj->store_url) + 1, T); return TLV; } Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid/squid/src/structs.h,v retrieving revision 1.530 retrieving revision 1.531 diff -u -r1.530 -r1.531 --- squid/src/structs.h 15 Nov 2007 04:43:55 -0000 1.530 +++ squid/src/structs.h 16 Nov 2007 11:38:46 -0000 1.531 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.530 2007/11/15 04:43:55 adrian Exp $ + * $Id: structs.h,v 1.531 2007/11/16 11:38:46 adrian Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -1704,6 +1704,7 @@ struct _MemObject { method_t method; char *url; + const char *store_url; mem_hdr data_hdr; squid_off_t inmem_hi; squid_off_t inmem_lo;