]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/carp.cc
Cleanup: zap CVS Id tags
[thirdparty/squid.git] / src / carp.cc
index 9c7fa65324a297ac9631c487c83f54c14d0e4a80..65bec9db0551bb3737cf4fad9673f5ef5d3651a3 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $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.
@@ -38,8 +38,6 @@
 #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;
@@ -54,6 +52,13 @@ peerSortWeight(const void *a, const void *b)
     return (*p1)->weight - (*p2)->weight;
 }
 
+static void
+carpRegisterWithCacheManager(void)
+{
+    CacheManager::GetInstance()->
+    registerAction("carp", "CARP information", carpCachemgr, 0, 1);
+}
+
 void
 carpInit(void)
 {
@@ -72,6 +77,10 @@ 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) {
@@ -152,12 +161,6 @@ carpInit(void)
     }
 }
 
-void
-carpRegisterWithCacheManager(CacheManager & manager)
-{
-    manager.registerAction("carp", "CARP information", carpCachemgr, 0, 1);
-}
-
 peer *
 carpSelectParent(HttpRequest * request)
 {
@@ -189,7 +192,7 @@ 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)) {
@@ -227,5 +230,3 @@ carpCachemgr(StoreEntry * sentry)
                           sumfetches ? (double) p->stats.fetches / sumfetches : -1.0);
     }
 }
-
-#endif