]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Fix up multicasting, credit to Martin Hamilton too
authorwessels <>
Fri, 7 Feb 1997 01:44:23 +0000 (01:44 +0000)
committerwessels <>
Fri, 7 Feb 1997 01:44:23 +0000 (01:44 +0000)
src/cache_cf.cc
src/comm.cc
src/neighbors.cc

index 715fbf46c686324d7ba19ecb6424e98bcb0fee8f..772950861100eb7b7095f7fae944bb6e7137fd0b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: cache_cf.cc,v 1.170 1997/02/06 18:02:08 wessels Exp $
+ * $Id: cache_cf.cc,v 1.171 1997/02/06 18:44:23 wessels Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -491,6 +491,8 @@ parseCacheHostLine(void)
            options |= NEIGHBOR_PROXY_ONLY;
        } else if (!strcasecmp(token, "no-query")) {
            options |= NEIGHBOR_NO_QUERY;
+       } else if (!strcasecmp(token, "multicast-responder")) {
+           options |= NEIGHBOR_MCAST_RESPONDER;
        } else if (!strncasecmp(token, "weight=", 7)) {
            weight = atoi(token + 7);
        } else if (!strncasecmp(token, "ttl=", 4)) {
index 76d922647ede7d467d58846d6e3a5042818feb63..a9b9e393d3f22645e2d25a1e46bbebaf24836305 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm.cc,v 1.131 1997/02/03 18:14:16 wessels Exp $
+ * $Id: comm.cc,v 1.132 1997/02/06 18:44:24 wessels Exp $
  *
  * DEBUG: section 5     Socket Functions
  * AUTHOR: Harvest Derived
@@ -1140,7 +1140,7 @@ comm_set_mcast_ttl(int fd, int mcast_ttl)
     debug(5, 10, "comm_set_mcast_ttl: setting multicast TTL %d on FD %d\n",
        mcast_ttl, fd);
     if (setsockopt(fd, IPPROTO_IP, IP_MULTICAST_TTL,
-           (char *) &mcast_ttl, sizeof(char)) < 0)
+           (char *) &mcast_ttl, sizeof(mcast_ttl)) < 0)
             debug(50, 1, "comm_set_mcast_ttl: FD %d, TTL: %d: %s\n",
            fd, mcast_ttl, xstrerror());
 #endif
index 47177746580a606a985d3424d5062a50fb17f0ea..8ba07d34d3b0436ad373b89e9c731c70cbcbbda0 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: neighbors.cc,v 1.109 1997/01/31 22:30:32 wessels Exp $
+ * $Id: neighbors.cc,v 1.110 1997/02/06 18:44:25 wessels Exp $
  *
  * DEBUG: section 15    Neighbor Routines
  * AUTHOR: Harvest Derived
@@ -154,6 +154,8 @@ neighborTypeStr(peer * e)
 {
     if (e->type == PEER_SIBLING)
        return "Sibling";
+    if (e->type == PEER_MULTICAST)
+       return "Multicast Group";
     return "Parent";
 }
 
@@ -198,6 +200,14 @@ neighborType(const peer * e, const request_t * request)
     return e->type;
 }
 
+/*
+ * peerWouldBePinged
+ *
+ * NOTE, this is a bit of a misnomer, really this function figures
+ * out if it is appropriate to fetch REQUEST from PEER.
+ * Whether or not we send the peer an ICP_OP_QUERY is determined
+ * in neighborsUdpPing.
+ */
 static int
 peerWouldBePinged(const peer * e, request_t * request)
 {
@@ -388,6 +398,8 @@ neighbors_open(int fd)
        next = e->next;
        debug(15, 1, "Configuring %s %s/%d/%d\n", neighborTypeStr(e),
            e->host, e->http_port, e->icp_port);
+       if (e->type == PEER_MULTICAST)
+           debug(15, 1, "    Multicast TTL = %d\n", e->mcast_ttl);
        if ((ia = ipcache_gethostbyname(e->host, IP_BLOCKING_LOOKUP)) == NULL) {
            debug(0, 0, "WARNING!!: DNS lookup for '%s' failed!\n", e->host);
            debug(0, 0, "THIS NEIGHBOR WILL BE IGNORED.\n");
@@ -451,12 +463,6 @@ neighborsUdpPing(protodispatch_data * proto)
     int flags;
     icp_common_t *query;
 
-    mem->e_pings_n_pings = 0;
-    mem->e_pings_n_acks = 0;
-    mem->e_pings_first_miss = NULL;
-    mem->w_rtt = 0;
-    mem->start_ping = current_time;
-
     if (Peers.peers_head == NULL)
        return 0;
     if (theOutIcpConnection < 0) {
@@ -467,6 +473,13 @@ neighborsUdpPing(protodispatch_data * proto)
     }
     if (entry->swap_status != NO_SWAP)
        fatal_dump("neighborsUdpPing: bad swap_status");
+
+    mem->e_pings_n_pings = 0;
+    mem->e_pings_n_acks = 0;
+    mem->e_pings_first_miss = NULL;
+    mem->w_rtt = 0;
+    mem->start_ping = current_time;
+
     for (i = 0, e = Peers.first_ping; i++ < Peers.n; e = e->next) {
        if (e == NULL)
            e = Peers.peers_head;
@@ -480,14 +493,18 @@ neighborsUdpPing(protodispatch_data * proto)
            continue;           /* next peer */
        if (e->options & NEIGHBOR_NO_QUERY)
            continue;
+       if (e->options & NEIGHBOR_MCAST_RESPONDER)
+           continue;
        /* the case below seems strange, but can happen if the
         * URL host is on the other side of a firewall */
        if (e->type == PEER_SIBLING)
            if (!BIT_TEST(request->flags, REQ_HIERARCHICAL))
                continue;
 
-       debug(15, 4, "neighborsUdpPing: pinging cache %s for '%s'\n",
+       debug(15, 4, "neighborsUdpPing: pinging peer %s for '%s'\n",
            e->host, url);
+        if (e->type == PEER_MULTICAST)
+           comm_set_mcast_ttl(theOutIcpConnection, e->mcast_ttl);
        reqnum = storeReqnum(entry, request->method);
        debug(15, 3, "neighborsUdpPing: key = '%s'\n", entry->key);
        debug(15, 3, "neighborsUdpPing: reqnum = %d\n", reqnum);
@@ -516,20 +533,15 @@ neighborsUdpPing(protodispatch_data * proto)
                PROTO_NONE);
        }
 
-       if (e->mcast_ttl > 0) {
-           /* XXX kill us off, so Squid won't expect a reply */
-           e->stats.ack_deficit = HIER_MAX_DEFICIT;
-       } else {
-           e->stats.ack_deficit++;
-       }
+       e->stats.ack_deficit++;
        e->stats.pings_sent++;
-
        debug(15, 3, "neighborsUdpPing: %s: ack_deficit = %d\n",
            e->host, e->stats.ack_deficit);
-
-       if (neighborUp(e)) {
+       if (e->type == PEER_MULTICAST) {
+               e->stats.ack_deficit = 0;
+       } else if (neighborUp(e)) {
            /* its alive, expect a reply from it */
-           mem->e_pings_n_pings++;
+               mem->e_pings_n_pings++;
        } else {
            /* Neighbor is dead; ping it anyway, but don't expect a reply */
            /* log it once at the threshold */