*** cache_cf.c.orig	Mon Sep 14 23:58:46 1998
--- cache_cf.c	Fri Oct 16 11:16:27 1998
***************
*** 799,807 ****
  	    p->options.no_netdb_exchange = 1;
  #if USE_CARP
  	} else if (!strncasecmp(token, "carp-load-factor=", 17)) {
- 	    if (p->type != PEER_PARENT)
- 		debug(3, 0) ("parse_peer: Ignoring carp-load-factor for non-parent %s/%d\n", p->host, p->http_port);
- 	    else
  		p->carp.load_factor = atof(token + 17);
  #endif
  #if DELAY_POOLS
--- 799,804 ----
*** carp.c.orig	Mon Aug 17 23:55:20 1998
--- carp.c	Mon Oct 19 10:53:40 1998
***************
*** 82,88 ****
  }
  
  peer *
! carpSelectParent(request_t * request)
  {
      const char *c;
      peer *p = NULL;
--- 82,88 ----
  }
  
  peer *
! carpSelectParent(request_t * request , int mode )
  {
      const char *c;
      peer *p = NULL;
***************
*** 97,102 ****
--- 97,112 ----
  	url_hash += (url_hash << 19) + *c;
      /* select peer */
      for (tp = Config.peers; tp; tp = tp->next) {
+ 
+         if (! tp->carp.load_factor)
+                 continue;
+         if ( tp->tcp_up != PEER_TCP_MAGIC_COUNT)
+                 continue;
+      	  if (neighborType(tp, request) != mode)
+             continue;
+         if ( !peerHTTPOkay(tp, request))
+                 continue;
+ 	
  	assert(tp->type == PEER_PARENT);
  	combined_hash = (url_hash ^ tp->carp.hash);
  	combined_hash += combined_hash * 0x62531965;
***************
*** 104,110 ****
  	combined_hash = combined_hash * tp->carp.load_multiplier;
  	debug(39, 3) ("carpSelectParent: %s combined_hash %d\n",
  	    tp->host, combined_hash);
! 	if ((combined_hash > high_score) && neighborUp(tp)) {
  	    p = tp;
  	    high_score = combined_hash;
  	}
--- 114,120 ----
  	combined_hash = combined_hash * tp->carp.load_multiplier;
  	debug(39, 3) ("carpSelectParent: %s combined_hash %d\n",
  	    tp->host, combined_hash);
! 	if (combined_hash > high_score) {
  	    p = tp;
  	    high_score = combined_hash;
  	}
*** peer_select.c.orig	Mon Oct 12 01:08:31 1998
--- peer_select.c	Mon Oct 19 10:49:36 1998
***************
*** 138,143 ****
--- 138,149 ----
  	*code = ROUNDROBIN_PARENT;
  	return p;
      }
+ #if USE_CARP
+     if ((p = carpSelectParent(request,PEER_PARENT))) {
+  	*code = CARP;
+ 	return p;
+     }
+ #endif
      if ((p = getFirstUpParent(request))) {
  	*code = FIRSTUP_PARENT;
  	return p;
***************
*** 322,328 ****
      }
  #endif
  #if USE_CARP
!     else if ((p = carpSelectParent(request))) {
  	hierarchyNote(&request->hier, CARP, &psstate->ping, p->host);
  	peerSelectCallback(psstate, p);
  	return;
--- 328,334 ----
      }
  #endif
  #if USE_CARP
!     else if ((p = carpSelectParent(request,PEER_SIBLING))) {
  	hierarchyNote(&request->hier, CARP, &psstate->ping, p->host);
  	peerSelectCallback(psstate, p);
  	return;
*** protos.h.orig	Mon Oct 19 11:29:08 1998
--- protos.h	Mon Oct 19 10:54:13 1998
***************
*** 1063,1069 ****
  
  #if USE_CARP
  extern void carpInit(void);
! extern peer *carpSelectParent(request_t *);
  #endif
  
  #if DELAY_POOLS
--- 1063,1069 ----
  
  #if USE_CARP
  extern void carpInit(void);
! extern peer *carpSelectParent(request_t *, int);
  #endif
  
  #if DELAY_POOLS