]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
reinstall ICP reqnum high-byte hack for encoding request method
authorwessels <>
Thu, 19 Mar 1998 14:13:29 +0000 (14:13 +0000)
committerwessels <>
Thu, 19 Mar 1998 14:13:29 +0000 (14:13 +0000)
call neighborsUdpAck() even when we don't have the cache key.
i.e. look up the StoreEntry in neighborsUdpAck() instead of
icpHandleIcpV2()

src/icmp.cc
src/icp_v2.cc
src/icp_v3.cc
src/neighbors.cc
src/protos.h
src/store.cc
src/store_key_md5.cc

index b10792114a545e49910764584fe4829ee488bc10..c2bda434b463584d93cc3b6cfedca16a69047ca0 100644 (file)
@@ -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 */
 
index 75d1869718a65a2e283154eeb767d05c849fbd82..6386b1d687d092d02c67bbe434f44241398f7960 100644 (file)
@@ -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:
index e657002e4bbdc635448c30d41fca1a62a61d1d0b..aec0430eeca9d78e71be54e7595d9e3f29779abb 100644 (file)
@@ -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:
index 66769fb684e15f1a3ec09d074ebcf07e150df54d..219bc5625d02d6470185d692ebff7196e45ccd07 100644 (file)
@@ -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)) {
index 0f9ae96be399943c9f39eff653aa7acc3c6c9760..213d334f9f35a6baa9df8d06170fc8d2be28bfd0 100644 (file)
@@ -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 *);
index 84d7804e91e7c35b0f29127e5deace8d528e405b..2b40ddfbc0433f59d9cbfb4b364a30a760c3543a 100644 (file)
@@ -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);
index 50d4a1ebae82749296615ecb357aa1f53553fb9f..5d4c96ebc208079ca7a6d1516aa4590c5947d65c 100644 (file)
@@ -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],