This was broken since
4310f8b: HTCP/ICP misused Store as a storage of
private entries during queries (e.g., see
neighborsUdpPing()/neighborsUdpAck()). A smarter HTCP/ICP
implementation would maintain its own StoreEntry cache for this purpose
(just like the existing queried_keys array for cache keys). However,
fixing this is beyond this issue scope.
debugs(15, 6, "neighborsUdpAck: opcode " << opcode << " '" << storeKeyText(key) << "'");
- if ((entry = Store::Root().findCallback(key)))
+ if ((entry = Store::Root().findCallbackXXX(key)))
mem = entry->mem_obj;
if ((p = whichPeer(from)))
void
neighborsHtcpReply(const cache_key * key, HtcpReplyData * htcp, const Ip::Address &from)
{
- StoreEntry *e = Store::Root().findCallback(key);
+ StoreEntry *e = Store::Root().findCallbackXXX(key);
MemObject *mem = NULL;
CachePeer *p;
peer_t ntype = PEER_NONE;
}
StoreEntry *
-Store::Controller::findCallback(const cache_key *key)
+Store::Controller::findCallbackXXX(const cache_key *key)
{
// We could check for mem_obj presence (and more), moving and merging some
// of the duplicated neighborsUdpAck() and neighborsHtcpReply() code here,
// but that would mean polluting Store with HTCP/ICP code. Instead, we
// should encapsulate callback-related data in a protocol-neutral MemObject
// member or use an HTCP/ICP-specific index rather than store_table.
- return peekAtLocal(key);
+
+ // cannot reuse peekAtLocal() because HTCP/ICP callbacks may use private keys
+ return static_cast<StoreEntry*>(hash_lookup(store_table, key));
}
/// \returns either an existing local reusable StoreEntry object or nil
/// \returns matching StoreEntry associated with local ICP/HTCP transaction
/// Warning: The returned StoreEntry is not synced and may be marked for
- /// deletion. Use it only for extracting transaction callback details.
- /// TODO: Group and return just that callback-related data instead?
- StoreEntry *findCallback(const cache_key *);
+ /// deletion. It can only be used for extracting transaction callback details.
+ /// New code should be designed to avoid this deprecated API.
+ StoreEntry *findCallbackXXX(const cache_key *);
/// Whether a transient entry with the given public key exists and (but) was
/// marked for removal some time ago; get(key) returns nil in such cases.