]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Added global Enabled flag to Adaptation::Config so that AccessCheck::Start
authorAlex Rousskov <rousskov@measurement-factory.com>
Fri, 4 Apr 2008 05:31:40 +0000 (23:31 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Fri, 4 Apr 2008 05:31:40 +0000 (23:31 -0600)
can check that instead of becoming dependent on each adaptation mechanism
and its config.onoff setting. Could have created a generic Registry of
all adaptation mechanisms instead.

src/adaptation/Config.cc
src/adaptation/Config.h
src/main.cc

index f2b361a05dbc2bad3b4851c2091fbe0a5e379e6b..aa3ca03691f3e4668c8d6c2c042de82f8c2df9b9 100644 (file)
@@ -43,6 +43,8 @@
 #include "adaptation/ServiceGroups.h"
 
 
+bool Adaptation::Config::Enabled = false;
+
 void
 Adaptation::Config::parseService()
 {
@@ -101,8 +103,11 @@ FinalizeEach(Collection &collection, const char *label)
 }
 
 void
-Adaptation::Config::Finalize()
+Adaptation::Config::Finalize(bool enabled)
 {
+    Enabled = enabled;
+    debugs(93,1, "Adaptation support is " << (Enabled ? "on" : "off."));
+
     FinalizeEach(AllServices(), "message adaptation services");
     FinalizeEach(AllGroups(), "message adaptation service groups");
     FinalizeEach(AllRules(), "message adaptation access rules");
index 72392a271812adf5fe8a3fc24e256c46b4698277..5de8be95e09a5ae7d0f0a199ec15ab28d8e64cfe 100644 (file)
@@ -25,7 +25,7 @@ class AccessRule;
 class Config
 {
 public:
-    static void Finalize();
+    static void Finalize(bool enable);
 
     static void ParseServiceSet(void);
     static void FreeServiceSet(void);
@@ -38,6 +38,7 @@ public:
     friend class AccessCheck;
 
 public:
+    static bool Enabled; // true if at least one adaptation mechanism is
 
     int onoff;
     int send_client_ip;
index 192bc7fe61c5578faa250fe26a896ebc21c443a2..8581ffd8d6e83fa8e13a456996dc6d4a716b2b7e 100644 (file)
@@ -1093,11 +1093,19 @@ mainInitialize(void)
     LoadableModulesConfigure(Config.loadable_module_names);
 #endif
 
+#if USE_ADAPTATION
+    bool enableAdaptation = false;
+
+    // We can remove this dependency on specific adaptation mechanisms
+    // if we create a generic Registry of such mechanisms. Should we?
 #if ICAP_CLIENT
     TheICAPConfig.finalize(); // must be after we load modules
+    enableAdaptation = TheICAPConfig.onoff;
 #endif
-#if USE_ADAPTATION
-    Adaptation::Config::Finalize(); // must be last adaptation-related finalize
+    // same for eCAP
+
+    // must be the last adaptation-related finalize
+    Adaptation::Config::Finalize(enableAdaptation);
 #endif