void
StoreEntry::setPrivateKey()
{
- const cache_key *newkey;
-
if (key && EBIT_TEST(flags, KEY_PRIVATE))
return; /* is already private */
hashDelete();
}
- if (mem_obj && mem_obj->hasUris()) {
+ if (mem_obj && mem_obj->hasUris())
mem_obj->id = getKeyCounter();
- newkey = storeKeyPrivate(mem_obj->storeId(), mem_obj->method, mem_obj->id);
- } else {
- newkey = storeKeyPrivate("JUNK", Http::METHOD_NONE, getKeyCounter());
- }
+ const cache_key *newkey = storeKeyPrivate();
assert(hash_lookup(store_table, newkey) == NULL);
EBIT_SET(flags, KEY_PRIVATE);
}
const cache_key *
-storeKeyPrivate(const char *url, const HttpRequestMethod& method, int id)
+storeKeyPrivate()
{
- static cache_key digest[SQUID_MD5_DIGEST_LENGTH];
- SquidMD5_CTX M;
- assert(id > 0);
- debugs(20, 3, "storeKeyPrivate: " << method << " " << url);
- SquidMD5Init(&M);
- SquidMD5Update(&M, (unsigned char *) &id, sizeof(id));
- SquidMD5Update(&M, (unsigned char *) &method, sizeof(method));
- SquidMD5Update(&M, (unsigned char *) url, strlen(url));
- SquidMD5Final(digest, &M);
- return digest;
+ // only the count field is required
+ // others just simplify searching for keys in a multi-process cache.log
+ static struct {
+ uint64_t count;
+ pid_t pid;
+ int32_t kid;
+ } key = { 0, getpid(), KidIdentifier };
+ assert(sizeof(key) == SQUID_MD5_DIGEST_LENGTH);
+ ++key.count;
+ return reinterpret_cast<cache_key*>(&key);
}
const cache_key *
const cache_key *storeKeyPublic(const char *, const HttpRequestMethod&);
const cache_key *storeKeyPublicByRequest(HttpRequest *);
const cache_key *storeKeyPublicByRequestMethod(HttpRequest *, const HttpRequestMethod&);
-const cache_key *storeKeyPrivate(const char *, const HttpRequestMethod&, int);
+const cache_key *storeKeyPrivate();
int storeKeyHashBuckets(int);
int storeKeyNull(const cache_key *);
void storeKeyInit(void);