Re: about peerGetSomeParent()

From: Henrik Nordstrom <hno@dont-contact.us>
Date: Wed, 19 Mar 2003 09:26:58 +0100

atit_ldce wrote:
>
> i have confusion in following code...
>
> if ((p = getDefaultParent(request))) {
> code = DEFAULT_PARENT;
> } else if ((p = getRoundRobinParent(request))) {
> code = ROUNDROBIN_PARENT;
> } else if ((p = getFirstUpParent(request))) {
> code = FIRSTUP_PARENT;
> } else if ((p = getAnyParent(request))) {
> code = ANY_OLD_PARENT;
> }
> if (code != HIER_NONE) {
> debug(44, 3) ("peerSelect: %s/%s\n", hier_strings[code], p->host);
> peerAddFwdServer(&ps->servers, p, code);
> }
>
> stmt p = getDefaultParent(request) are assignment stmt
> so outcome of if cond is definately 0

The if is a long chain of if ... else if ... else if ... else if ...,
and the order of the ifs tell the priority of these different parent
selection algorithms.

  1. default (by cache_peer default option)
  2. round-tobin (by cache_peer round-robin option)
  3. first alive parent (by order of your cache_peer lines)
  4. any parent

I don't think 4 ever happens in the current code.

> in this case
> code will be HIER_NONE.
>
> does it indicate error in code or it has any other purpose?

HIER_NONE here just indicates that no parent has been selected.

Regards
Henrik
Received on Wed Mar 19 2003 - 02:02:43 MST

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