From: wessels <> Date: Thu, 19 Mar 1998 14:13:29 +0000 (+0000) Subject: reinstall ICP reqnum high-byte hack for encoding request method X-Git-Tag: SQUID_3_0_PRE1~3796 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ad333565132777aa5d69b29913412757c131a2a;p=thirdparty%2Fsquid.git reinstall ICP reqnum high-byte hack for encoding request method call neighborsUdpAck() even when we don't have the cache key. i.e. look up the StoreEntry in neighborsUdpAck() instead of icpHandleIcpV2() --- diff --git a/src/icmp.cc b/src/icmp.cc index b10792114a..c2bda434b4 100644 --- a/src/icmp.cc +++ b/src/icmp.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -163,7 +163,6 @@ static void 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)); @@ -173,15 +172,10 @@ icmpHandleSourcePing(const struct sockaddr_in *from, const char *buf) } 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 */ diff --git a/src/icp_v2.cc b/src/icp_v2.cc index 75d1869718..6386b1d687 100644 --- a/src/icp_v2.cc +++ b/src/icp_v2.cc @@ -143,6 +143,7 @@ icpHandleIcpV2(int fd, struct sockaddr_in from, char *buf, int len) 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 @@ -152,11 +153,12 @@ icpHandleIcpV2(int fd, struct sockaddr_in from, char *buf, int len) 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; @@ -187,7 +189,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); + key = storeKeyPublic(url, method); entry = storeGet(key); debug(12, 5) ("icpHandleIcpV2: OPCODE %s\n", icp_opcode_str[header.opcode]); if (icpCheckUdpHit(entry, icp_request)) { @@ -227,18 +229,11 @@ icpHandleIcpV2(int fd, struct sockaddr_in from, char *buf, int len) 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: diff --git a/src/icp_v3.cc b/src/icp_v3.cc index e657002e4b..aec0430eec 100644 --- a/src/icp_v3.cc +++ b/src/icp_v3.cc @@ -12,6 +12,7 @@ icpHandleIcpV3(int fd, struct sockaddr_in from, char *buf, int len) 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 @@ -21,11 +22,12 @@ icpHandleIcpV3(int fd, struct sockaddr_in from, char *buf, int len) 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; @@ -49,7 +51,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); + key = storeKeyPublic(url, method); entry = storeGet(key); debug(12, 5) ("icpHandleIcpV3: OPCODE %s\n", icp_opcode_str[header.opcode]); @@ -89,18 +91,11 @@ icpHandleIcpV3(int fd, struct sockaddr_in from, char *buf, int len) 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: diff --git a/src/neighbors.cc b/src/neighbors.cc index 66769fb684..219bc5625d 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -618,43 +618,58 @@ ignoreMulticastReply(peer * p, MemObject * mem) * 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)) { diff --git a/src/protos.h b/src/protos.h index 0f9ae96be3..213d334f9f 100644 --- a/src/protos.h +++ b/src/protos.h @@ -482,7 +482,7 @@ extern int neighborsUdpPing(request_t *, 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 *); diff --git a/src/store.cc b/src/store.cc index 84d7804e91..2b40ddfbc0 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1,6 +1,6 @@ /* - * $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 @@ -158,7 +158,7 @@ static void destroy_MemObject(StoreEntry *); 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 *); /* @@ -342,12 +342,12 @@ storeGet(const cache_key * key) } 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 @@ -363,10 +363,10 @@ storeSetPrivateKey(StoreEntry * e) 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); diff --git a/src/store_key_md5.cc b/src/store_key_md5.cc index 50d4a1ebae..5d4c96ebc2 100644 --- a/src/store_key_md5.cc +++ b/src/store_key_md5.cc @@ -66,7 +66,8 @@ storeKeyPrivate(const char *url, method_t method, int num) 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],