call neighborsUdpAck() even when we don't have the cache key.
i.e. look up the StoreEntry in neighborsUdpAck() instead of
icpHandleIcpV2()
/*
- * $Id: icmp.cc,v 1.56 1998/03/03 00:31:08 rousskov Exp $
+ * $Id: icmp.cc,v 1.57 1998/03/19 07:13:29 wessels Exp $
*
* DEBUG: section 37 ICMP Routines
* AUTHOR: Duane Wessels
icmpHandleSourcePing(const struct sockaddr_in *from, const char *buf)
{
const cache_key *key;
- StoreEntry *entry;
icp_common_t header;
const char *url;
xmemcpy(&header, buf, sizeof(icp_common_t));
} else {
key = storeKeyPublic(url, METHOD_GET);
}
- debug(37, 3) ("icmpHandleSourcePing: from %s, key=%s\n",
- inet_ntoa(from->sin_addr),
- key);
- if ((entry = storeGet(key)) == NULL)
- return;
- if (entry->lock_count == 0)
- return;
+ debug(37, 3) ("icmpHandleSourcePing: from %s, key '%s'\n",
+ inet_ntoa(from->sin_addr), storeKeyText(key));
/* call neighborsUdpAck even if ping_status != PING_WAITING */
- neighborsUdpAck(url, &header, from, entry);
+ neighborsUdpAck(key, &header, from);
}
#endif /* USE_ICMP */
icp_common_t *reply;
int src_rtt = 0;
u_num32 flags = 0;
+ method_t method;
xmemcpy(&header, buf, sizeof(icp_common_t));
/*
* Only these fields need to be converted
header.flags = ntohl(header.flags);
header.pad = ntohl(header.pad);
+ method = header.reqnum >> 24;
switch (header.opcode) {
case ICP_QUERY:
/* We have a valid packet */
url = buf + sizeof(icp_common_t) + sizeof(u_num32);
- if ((icp_request = urlParse(METHOD_GET, url)) == NULL) {
+ if ((icp_request = urlParse(method, url)) == NULL) {
reply = icpCreateMessage(ICP_ERR, 0, url, header.reqnum, 0);
icpUdpSend(fd, &from, reply, LOG_UDP_INVALID, PROTO_NONE);
break;
flags |= ICP_FLAG_SRC_RTT;
}
/* The peer is allowed to use this cache */
- key = storeKeyPublic(url, METHOD_GET);
+ key = storeKeyPublic(url, method);
entry = storeGet(key);
debug(12, 5) ("icpHandleIcpV2: OPCODE %s\n", icp_opcode_str[header.opcode]);
if (icpCheckUdpHit(entry, icp_request)) {
inet_ntoa(from.sin_addr),
url);
if (neighbors_do_private_keys && header.reqnum)
- key = storeKeyPrivate(url, METHOD_GET, header.reqnum);
+ key = storeKeyPrivate(url, method, header.reqnum);
else
- key = storeKeyPublic(url, METHOD_GET);
- debug(12, 3) ("icpHandleIcpV2: Looking for key '%s'\n",
- storeKeyText(key));
- if ((entry = storeGet(key)) == NULL) {
- debug(12, 3) ("icpHandleIcpV2: Ignoring %s for NULL Entry.\n",
- icp_opcode_str[header.opcode]);
- } else {
- /* call neighborsUdpAck even if ping_status != PING_WAITING */
- neighborsUdpAck(url, &header, &from, entry);
- }
+ key = storeKeyPublic(url, method);
+ /* call neighborsUdpAck even if ping_status != PING_WAITING */
+ neighborsUdpAck(key, &header, &from);
break;
case ICP_INVALID:
request_t *icp_request = NULL;
int allow = 0;
aclCheck_t checklist;
+ method_t method;
xmemcpy(&header, buf, sizeof(icp_common_t));
/*
* Only these fields need to be converted
header.flags = ntohl(header.flags);
header.pad = ntohl(header.pad);
+ method = header.reqnum >> 24;
switch (header.opcode) {
case ICP_QUERY:
/* We have a valid packet */
url = buf + sizeof(icp_common_t) + sizeof(u_num32);
- if ((icp_request = urlParse(METHOD_GET, url)) == NULL) {
+ if ((icp_request = urlParse(method, url)) == NULL) {
reply = icpCreateMessage(ICP_ERR, 0, url, header.reqnum, 0);
icpUdpSend(fd, &from, reply, LOG_UDP_INVALID, PROTO_NONE);
break;
break;
}
/* The peer is allowed to use this cache */
- key = storeKeyPublic(url, METHOD_GET);
+ key = storeKeyPublic(url, method);
entry = storeGet(key);
debug(12, 5) ("icpHandleIcpV3: OPCODE %s\n",
icp_opcode_str[header.opcode]);
inet_ntoa(from.sin_addr),
url);
if (neighbors_do_private_keys && header.reqnum)
- key = storeKeyPrivate(url, METHOD_GET, header.reqnum);
+ key = storeKeyPrivate(url, method, header.reqnum);
else
- key = storeKeyPublic(url, METHOD_GET);
- debug(12, 3) ("icpHandleIcpV3: Looking for key '%s'\n",
- storeKeyText(key));
- if ((entry = storeGet(key)) == NULL) {
- debug(12, 3) ("icpHandleIcpV3: Ignoring %s for NULL Entry.\n",
- icp_opcode_str[header.opcode]);
- } else {
- /* call neighborsUdpAck even if ping_status != PING_WAITING */
- neighborsUdpAck(url, &header, &from, entry);
- }
+ key = storeKeyPublic(url, method);
+ /* call neighborsUdpAck even if ping_status != PING_WAITING */
+ neighborsUdpAck(key, &header, &from);
break;
case ICP_INVALID:
/*
- * $Id: neighbors.cc,v 1.180 1998/03/16 21:45:02 wessels Exp $
+ * $Id: neighbors.cc,v 1.181 1998/03/19 07:13:31 wessels Exp $
*
* DEBUG: section 15 Neighbor Routines
* AUTHOR: Harvest Derived
* If a hit process is already started, then sobeit
*/
void
-neighborsUdpAck(const char *url, icp_common_t * header, const struct sockaddr_in *from, StoreEntry * entry)
+neighborsUdpAck(const cache_key * key, icp_common_t * header, const struct sockaddr_in *from)
{
peer *p = NULL;
- MemObject *mem = entry->mem_obj;
+ StoreEntry *entry;
+ MemObject *mem = NULL;
peer_t ntype = PEER_NONE;
char *opcode_d;
icp_opcode opcode = (icp_opcode) header->opcode;
- debug(15, 6) ("neighborsUdpAck: opcode %d '%s'\n", (int) opcode, url);
+ debug(15, 6) ("neighborsUdpAck: opcode %d '%s'\n",
+ (int) opcode, storeKeyText(key));
+ if (NULL != (entry = storeGet(key)))
+ mem = entry->mem_obj;
if ((p = whichPeer(from)))
neighborAlive(p, mem, header);
if (opcode > ICP_END)
return;
opcode_d = icp_opcode_str[opcode];
+ /* Does the entry exist? */
+ if (NULL == entry) {
+ debug(12, 3) ("neighborsUdpAck: Cache key '%s' not found\n",
+ storeKeyText(key));
+ neighborCountIgnored(p, opcode);
+ return;
+ }
/* check if someone is already fetching it */
if (EBIT_TEST(entry->flag, ENTRY_DISPATCHED)) {
- debug(15, 3) ("neighborsUdpAck: '%s' already being fetched.\n", url);
+ debug(15, 3) ("neighborsUdpAck: '%s' already being fetched.\n",
+ storeKeyText(key));
neighborCountIgnored(p, opcode);
return;
}
if (mem == NULL) {
- debug(15, 2) ("Ignoring %s for missing mem_obj: %s\n", opcode_d, url);
+ debug(15, 2) ("Ignoring %s for missing mem_obj: %s\n",
+ opcode_d, storeKeyText(key));
neighborCountIgnored(p, opcode);
return;
}
if (entry->ping_status != PING_WAITING) {
- debug(15, 2) ("neighborsUdpAck: Unexpected %s for %s\n", opcode_d, url);
+ debug(15, 2) ("neighborsUdpAck: Unexpected %s for %s\n",
+ opcode_d, storeKeyText(key));
neighborCountIgnored(p, opcode);
return;
}
if (entry->lock_count == 0) {
- debug(12, 1) ("neighborsUdpAck: '%s' has no locks\n", url);
+ debug(12, 1) ("neighborsUdpAck: '%s' has no locks\n",
+ storeKeyText(key));
neighborCountIgnored(p, opcode);
return;
}
debug(15, 3) ("neighborsUdpAck: %s for '%s' from %s \n",
- opcode_d, url, p ? p->host : "source");
+ opcode_d, storeKeyText(key), p ? p->host : "source");
if (p)
ntype = neighborType(p, mem->request);
if (ignoreMulticastReply(p, mem)) {
void *data,
int *exprep);
extern void neighborAddAcl(const char *, const char *);
-extern void neighborsUdpAck(const char *, icp_common_t *, const struct sockaddr_in *, StoreEntry *);
+extern void neighborsUdpAck(const cache_key *, icp_common_t *, const struct sockaddr_in *);
extern void neighborAdd(const char *, const char *, int, int, int, int, int);
extern void neighbors_open(int);
extern peer *peerFindByName(const char *);
/*
- * $Id: store.cc,v 1.394 1998/03/12 02:20:09 wessels Exp $
+ * $Id: store.cc,v 1.395 1998/03/19 07:13:33 wessels Exp $
*
* DEBUG: section 20 Storeage Manager
* AUTHOR: Harvest Derived
static void destroy_MemObjectData(MemObject *);
static void destroy_StoreEntry(StoreEntry *);
static void storePurgeMem(StoreEntry *);
-static unsigned int getKeyCounter(void);
+static unsigned int getKeyCounter(method_t);
static int storeKeepInMemory(const StoreEntry *);
/*
}
static unsigned int
-getKeyCounter(void)
+getKeyCounter(method_t method)
{
static unsigned int key_counter = 0;
if (++key_counter == (1 << 24))
key_counter = 1;
- return key_counter;
+ return (method << 24) | key_counter;
}
void
storeHashDelete(e);
}
if (mem != NULL) {
- mem->reqnum = getKeyCounter();
+ mem->reqnum = getKeyCounter(mem->method);
newkey = storeKeyPrivate(mem->url, mem->method, mem->reqnum);
} else {
- newkey = storeKeyPrivate("JUNK", METHOD_NONE, getKeyCounter());
+ newkey = storeKeyPrivate("JUNK", METHOD_NONE, getKeyCounter(METHOD_NONE));
}
assert(hash_lookup(store_table, newkey) == NULL);
storeHashInsert(e, newkey);
int n;
char key_buf[MAX_URL + 100];
assert(num > 0);
- debug(20, 3) ("storeKeyPrivate: '%s'\n", url);
+ debug(20, 3) ("storeKeyPrivate: %s %s\n",
+ RequestMethodStr[method], url);
n = snprintf(key_buf, MAX_URL + 100, "%d %s %s",
num,
RequestMethodStr[method],