2.2.DEVEL3: prefer_direct, always_direct, never_direct

From: Henrik Nordstrom <hno@dont-contact.us>
Date: Mon, 08 Mar 1999 00:58:23 +0100

prefer_direct in it's current form it seems rather useless. It is more
like "try everything direct" or "try everything by a parent" (where
"everything" is everything not matching ICP peer selection)

It should probably be something

1. If always_direct then direct
2. If never_direct then use a parent
3. If not prefer_direct then try using a parent
4. If the request is hierarchical then try using a parent
5. else go direct (also direct if the parent fails and not never_direct)

Note:
Instead of selecting one parent probably all parents should be selected
in priority order. Today only one parent is selected. This is mainly of
importance in the never_direct case where today the end user may see a
error message if the selected parent goes down even if there are other
parents available that could handle the request.

Hmm.. thinking a bit further on never_direct and parent selection.
Probably dead parents should be added as well, in case one of them comes
alive during the request.

Attached is a 2.2.DEVEL3 patch which changes the selection to what is
listed above, and a hack for adding all alive parents on never_direct.
[replaces squid-2.2.DEVEL3.prefer_always_direct.patch sent earlier]

/Henrik

    [ Part 2: "Attached Text" ]

Index: squid/src/peer_select.c
diff -u squid/src/peer_select.c:1.1.1.26 squid/src/peer_select.c:1.1.1.26.2.4
--- squid/src/peer_select.c:1.1.1.26 Sun Feb 14 23:30:04 1999
+++ squid/src/peer_select.c Mon Mar 8 00:44:42 1999
@@ -88,6 +88,7 @@
 static void peerGetSomeNeighborReplies(ps_state *);
 static void peerGetSomeDirect(ps_state *);
 static void peerGetSomeParent(ps_state *);
+static void peerGetAllParents(ps_state *);
 static void peerAddFwdServer(FwdServer **, peer *, hier_code);
 
 static void
@@ -278,11 +279,20 @@
         peerGetSomeNeighborReplies(ps);
         entry->ping_status = PING_DONE;
     }
- if (Config.onoff.prefer_direct)
+ switch (ps->direct) {
+ case DIRECT_YES:
         peerGetSomeDirect(ps);
- peerGetSomeParent(ps);
- if (!Config.onoff.prefer_direct)
+ break;
+ case DIRECT_NO:
+ peerGetSomeParent(ps);
+ peerGetAllParents(ps);
+ break;
+ default:
+ if (request->flags.hierarchical || !Config.onoff.prefer_direct)
+ peerGetSomeParent(ps);
         peerGetSomeDirect(ps);
+ break;
+ }
     peerSelectCallback(ps);
 }
 
@@ -433,6 +443,31 @@
         debug(44, 3) ("peerSelect: %s/%s\n", hier_strings[code], p->host);
         peerAddFwdServer(&ps->servers, p, code);
     }
+}
+
+/* Adds alive parents. Used as a last resort for never_direct.
+ */
+static void
+peerGetAllParents(ps_state *ps)
+{
+ peer *p;
+ request_t *request = ps->request;
+ /* Add all alive parents */
+ for (p = Config.peers; p; p = p->next) {
+ /* XXX: neighbors.c lacks a public interface for enumerating
+ * parents to a request so we have to dig some here..
+ */
+ if (neighborType(p, request) != PEER_PARENT)
+ continue;
+ if (!peerHTTPOkay(p, request))
+ continue;
+ debug(15, 3) ("peerGetAllParents: adding alive parent %s\n", p->host);
+ peerAddFwdServer(&ps->servers, p, ANY_OLD_PARENT);
+ }
+ /* XXX: should add dead parents here, but it is currently
+ * not possible to find out which parents are dead or which
+ * simply are not configured to handle the request.
+ */
 }
 
 static void
Received on Tue Jul 29 2003 - 13:15:57 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:12:04 MST