/*
- * $Id: carp.cc,v 1.27 2008/01/14 12:13:49 hno Exp $
+ * $Id$
*
* DEBUG: section 39 Cache Array Routing Protocol
* AUTHOR: Henrik Nordstrom
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
#include "CacheManager.h"
#include "Store.h"
-#if USE_CARP
-
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n))))
static int n_carp_peers = 0;
return (*p1)->weight - (*p2)->weight;
}
+static void
+carpRegisterWithCacheManager(void)
+{
+ CacheManager::GetInstance()->
+ registerAction("carp", "CARP information", carpCachemgr, 0, 1);
+}
+
void
carpInit(void)
{
safe_free(carp_peers);
n_carp_peers = 0;
+
+ /* initialize cache manager before we have a chance to leave the execution path */
+ carpRegisterWithCacheManager();
+
/* find out which peers we have */
for (p = Config.peers; p; p = p->next) {
}
}
-void
-carpRegisterWithCacheManager(CacheManager & manager)
-{
- manager.registerAction("carp", "CARP information", carpCachemgr, 0, 1);
-}
-
peer *
carpSelectParent(HttpRequest * request)
{
combined_hash += combined_hash * 0x62531965;
combined_hash = ROTATE_LEFT(combined_hash, 21);
score = combined_hash * tp->carp.load_multiplier;
- debugs(39, 3, "carpSelectParent: " << tp->name << " combined_hash " << combined_hash <<
+ debugs(39, 3, "carpSelectParent: " << tp->name << " combined_hash " << combined_hash <<
" score " << std::setprecision(0) << score);
if ((score > high_score) && peerHTTPOkay(tp, request)) {
sumfetches ? (double) p->stats.fetches / sumfetches : -1.0);
}
}
-
-#endif