]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Added storeGetPublic() mostly so that we can check both old and new
authorwessels <>
Mon, 21 Sep 1998 12:52:13 +0000 (12:52 +0000)
committerwessels <>
Mon, 21 Sep 1998 12:52:13 +0000 (12:52 +0000)
style cache keys.  It doesn't seem to make things less elegant, so maybe
its a good idea anyway.

src/htcp.cc
src/http.cc
src/icp_v2.cc
src/icp_v3.cc
src/mime.cc
src/protos.h
src/store.cc
src/store_key_md5.cc
src/urn.cc

index bb96c0e44e39737469afeb3c6dcb818b5a8e0565..2f3fefd9eeef5648f459dbb13225ace27bb5ef00 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: htcp.cc,v 1.22 1998/09/04 23:04:48 wessels Exp $
+ * $Id: htcp.cc,v 1.23 1998/09/21 06:52:13 wessels Exp $
  *
  * DEBUG: section 31    Hypertext Caching Protocol
  * AUTHOR: Duane Wesssels
@@ -674,8 +674,7 @@ htcpHandleTstRequest(htcpDataHeader * dhdr, char *buf, int sz, struct sockaddr_i
        s->version);
     m = urlParseMethod(s->method);
     debug(31, 1) ("htcpHandleTstRequest: %s\n", s->req_hdrs);
-    key = storeKeyPublic(s->uri, m);
-    e = storeGet(key);
+    e = storeGetPublic(s->uri, m);
     if (NULL == e) {
        /* cache miss */
        htcpTstReply(dhdr, NULL, NULL, from);
index 89b85a465715ad5b0324cb3db4a4ff6bc4cca9e6..71f6d660dbda92d92944e42352b159b16e984560 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: http.cc,v 1.322 1998/09/19 17:06:05 wessels Exp $
+ * $Id: http.cc,v 1.323 1998/09/21 06:52:14 wessels Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -132,7 +132,6 @@ static void
 httpMaybeRemovePublic(StoreEntry * e, http_status status)
 {
     int remove = 0;
-    const cache_key *key;
     StoreEntry *pe;
     if (!EBIT_TEST(e->flags, KEY_PRIVATE))
        return;
@@ -160,15 +159,13 @@ httpMaybeRemovePublic(StoreEntry * e, http_status status)
     if (!remove)
        return;
     assert(e->mem_obj);
-    key = storeKeyPublic(e->mem_obj->url, e->mem_obj->method);
-    if ((pe = storeGet(key)) != NULL) {
+    if ((pe = storeGetPublic(e->mem_obj->url, e->mem_obj->method)) != NULL) {
        assert(e != pe);
        storeRelease(pe);
     }
     if (e->mem_obj->method == METHOD_GET) {
        /* A fresh GET should eject old HEAD objects */
-       key = storeKeyPublic(e->mem_obj->url, METHOD_HEAD);
-       if ((pe = storeGet(key)) != NULL) {
+       if ((pe = storeGetPublic(e->mem_obj->url, METHOD_HEAD)) != NULL) {
            assert(e != pe);
            storeRelease(pe);
        }
index 793d7c3475fd6192d2d75ae892aeafe45d08ecf0..5b3f1c65fbdcc7b52ad733ba4c05260cd04cadfb 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: icp_v2.cc,v 1.52 1998/09/15 19:37:49 wessels Exp $
+ * $Id: icp_v2.cc,v 1.53 1998/09/21 06:52:15 wessels Exp $
  *
  * DEBUG: section 12    Internet Cache Protocol
  * AUTHOR: Duane Wessels
@@ -243,8 +243,7 @@ icpHandleIcpV2(int fd, struct sockaddr_in from, char *buf, int len)
                flags |= ICP_FLAG_SRC_RTT;
        }
        /* The peer is allowed to use this cache */
-       key = storeKeyPublic(url, METHOD_GET);
-       entry = storeGet(key);
+       entry = storeGetPublic(url, METHOD_GET);
        debug(12, 5) ("icpHandleIcpV2: OPCODE %s\n", icp_opcode_str[header.opcode]);
        if (icpCheckUdpHit(entry, icp_request)) {
            reply = icpCreateMessage(ICP_HIT, flags, url, header.reqnum, src_rtt);
index a0de45cb83ca118f4be73a385c8286fe2228fe1a..09287414836fe4dfe26da72616e65dbeda73afa9 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: icp_v3.cc,v 1.25 1998/09/11 17:07:44 wessels Exp $
+ * $Id: icp_v3.cc,v 1.26 1998/09/21 06:52:16 wessels Exp $
  *
  * DEBUG: section 12    Internet Cache Protocol
  * AUTHOR: Duane Wessels
@@ -90,8 +90,7 @@ icpHandleIcpV3(int fd, struct sockaddr_in from, char *buf, int len)
            break;
        }
        /* The peer is allowed to use this cache */
-       key = storeKeyPublic(url, METHOD_GET);
-       entry = storeGet(key);
+       entry = storeGetPublic(url, METHOD_GET);
        debug(12, 5) ("icpHandleIcpV3: OPCODE %s\n",
            icp_opcode_str[header.opcode]);
        if (icpCheckUdpHit(entry, icp_request)) {
index 9d1e50638a716ca5ed964597f910edb0e1d7b66b..641aa7d67668995d79a90e5ef4119d53ad369635 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: mime.cc,v 1.80 1998/09/19 17:06:06 wessels Exp $
+ * $Id: mime.cc,v 1.81 1998/09/21 06:52:17 wessels Exp $
  *
  * DEBUG: section 25    MIME Parsing
  * AUTHOR: Harvest Derived
@@ -376,14 +376,12 @@ mimeLoadIconFile(const char *icon)
     LOCAL_ARRAY(char, path, MAXPATHLEN);
     LOCAL_ARRAY(char, url, MAX_URL);
     char *buf;
-    const cache_key *key;
     const char *type = mimeGetContentType(icon);
     if (type == NULL)
        fatal("Unknown icon format while reading mime.conf\n");
     buf = internalLocalUri("/squid-internal-static/icons/", icon);
     xstrncpy(url, buf, MAX_URL);
-    key = storeKeyPublic(url, METHOD_GET);
-    if (storeGet(key))
+    if (storeGetPublic(url, METHOD_GET))
        return;
     snprintf(path, MAXPATHLEN, "%s/%s", Config.icons.directory, icon);
     fd = file_open(path, O_RDONLY, NULL, NULL, NULL);
index 568615d11d6c4305ea3ffe390b128bd4d632925f..eb5996b237c7991b279d6d21442d5f2a8dacbca4 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.269 1998/09/21 06:42:57 wessels Exp $
+ * $Id: protos.h,v 1.270 1998/09/21 06:52:19 wessels Exp $
  *
  *
  * SQUID Internet Object Cache  http://squid.nlanr.net/Squid/
@@ -734,6 +734,7 @@ extern void stmemFreeData(mem_hdr *);
  */
 extern StoreEntry *new_StoreEntry(int, const char *, const char *);
 extern StoreEntry *storeGet(const cache_key *);
+extern StoreEntry *storeGetPublic(const char *uri, const method_t method);
 extern StoreEntry *storeCreateEntry(const char *, const char *, request_flags, method_t);
 extern void storeSetPublicKey(StoreEntry *);
 extern void storeComplete(StoreEntry *);
@@ -812,7 +813,8 @@ extern cache_key *storeKeyCopy(cache_key *, const cache_key *);
 extern void storeKeyFree(const cache_key *);
 extern const cache_key *storeKeyScan(const char *);
 extern const char *storeKeyText(const cache_key *);
-extern const cache_key *storeKeyPublic(const char *, method_t);
+extern const cache_key *storeKeyPublic(const char *, const method_t);
+extern const cache_key *storeKeyPublicOld(const char *, method_t);
 extern const cache_key *storeKeyPrivate(const char *, method_t, int);
 extern int storeKeyHashBuckets(int);
 extern int storeKeyNull(const cache_key *);
index 77d1c5b0c593bfb2d8f87da33f27cedfa37711d0..046a9da6ee80e800f92ee18a94ee06879ebbc5d9 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store.cc,v 1.462 1998/09/19 17:06:12 wessels Exp $
+ * $Id: store.cc,v 1.463 1998/09/21 06:52:22 wessels Exp $
  *
  * DEBUG: section 20    Storage Manager
  * AUTHOR: Harvest Derived
@@ -279,6 +279,20 @@ storeGet(const cache_key * key)
     return (StoreEntry *) hash_lookup(store_table, key);
 }
 
+StoreEntry *
+storeGetPublic(const char *uri, const method_t method)
+{
+    cache_key *key;
+    StoreEntry *e;
+    key = storeKeyPublic(uri, method);
+    e = storeGet(key);
+    if (e == NULL && squid_curtime < 909000000) {
+       key = storeKeyPublicOld(uri, method);
+       e = storeGet(key);
+    }
+    return storeGet(key);
+}
+
 static int
 getKeyCounter(void)
 {
index f1e55355ca948133c808f2d998e3e38d233bb483..6e94797c6319492c9443a44380c9119b1582524b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_key_md5.cc,v 1.16 1998/09/15 19:38:02 wessels Exp $
+ * $Id: store_key_md5.cc,v 1.17 1998/09/21 06:52:23 wessels Exp $
  *
  * DEBUG: section 20    Storage Manager MD5 Cache Keys
  * AUTHOR: Duane Wessels
@@ -108,7 +108,7 @@ storeKeyPrivate(const char *url, method_t method, int id)
 }
 
 const cache_key *
-storeKeyPublic(const char *url, method_t method)
+storeKeyPublic(const char *url, const method_t method)
 {
     static cache_key digest[MD5_DIGEST_CHARS];
     MD5_CTX M;
@@ -119,6 +119,25 @@ storeKeyPublic(const char *url, method_t method)
     return digest;
 }
 
+/*
+ * Compatibility transition period.  Remove this after Oct 21, 1998
+ */
+const cache_key *
+storeKeyPublicOld(const char *url, method_t method)
+{
+    static cache_key digest[MD5_DIGEST_CHARS];
+    MD5_CTX M;
+    int n;
+    char key_buf[MAX_URL + 100];
+    n = snprintf(key_buf, sizeof(key_buf), "%s %s",
+       RequestMethodStr[method],
+       url);
+    MD5Init(&M);
+    MD5Update(&M, (unsigned char *) key_buf, n);
+    MD5Final(digest, &M);
+    return digest;
+}
+
 const cache_key *
 storeKeyDup(const cache_key * key)
 {
index d2ee372d76f3f57457f5f8d7a877803896894456..ee1adbf9df00e496b3c82b06ac153c9e6e4ecbc6 100644 (file)
@@ -1,7 +1,7 @@
 
 /*
  *
- * $Id: urn.cc,v 1.45 1998/09/14 22:18:04 wessels Exp $
+ * $Id: urn.cc,v 1.47 1998/09/21 06:52:23 wessels Exp $
  *
  * DEBUG: section 52    URN Parsing
  * AUTHOR: Kostas Anagnostakis
 
 #include "squid.h"
 
-enum {
-    URN_FORCE_MENU
-};
-
 typedef struct {
     StoreEntry *entry;
     StoreEntry *urlres_e;
@@ -104,7 +100,6 @@ urnStart(request_t * r, StoreEntry * e)
 {
     LOCAL_ARRAY(char, urlres, 4096);
     request_t *urlres_r = NULL;
-    const cache_key *k;
     const char *t;
     char *host;
     UrnState *urnState;
@@ -131,7 +126,6 @@ urnStart(request_t * r, StoreEntry * e)
     }
     snprintf(urlres, 4096, "http://%s/uri-res/N2L?urn:%s", host, strBuf(r->urlpath));
     safe_free(host);
-    k = storeKeyPublic(urlres, METHOD_GET);
     urlres_r = urlParse(METHOD_GET, urlres);
     if (urlres_r == NULL) {
        debug(52, 3) ("urnStart: Bad uri-res URL %s\n", urlres);
@@ -141,7 +135,7 @@ urnStart(request_t * r, StoreEntry * e)
        return;
     }
     httpHeaderPutStr(&urlres_r->header, HDR_ACCEPT, "text/plain");
-    if ((urlres_e = storeGet(k)) == NULL) {
+    if ((urlres_e = storeGetPublic(urlres, METHOD_GET)) == NULL) {
        urlres_e = storeCreateEntry(urlres, urlres, null_request_flags, METHOD_GET);
        storeClientListAdd(urlres_e, urnState);
        fwdStart(-1, urlres_e, urlres_r, no_addr);
@@ -314,7 +308,6 @@ urnParseReply(const char *inbuf, method_t m)
     char *token;
     char *url;
     char *host;
-    const cache_key *key;
     int rtt;
     url_entry *list;
     url_entry *old;
@@ -340,11 +333,10 @@ urnParseReply(const char *inbuf, method_t m)
            debug(52, 3) ("urnParseReply: Pinging %s\n", host);
            netdbPingSite(host);
        }
-       key = storeKeyPublic(url, m);
        list[i].url = url;
        list[i].host = xstrdup(host);
        list[i].rtt = rtt;
-       list[i].flags.cached = storeGet(key) ? 1 : 0;
+       list[i].flags.cached = storeGetPublic(url, m) ? 1 : 0;
        i++;
     }
     debug(0, 0) ("urnParseReply: Found %d URLs\n", i);