]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
bug 2591: adaptation_access does not work
authorChristos Tsantilas <chtsanti@users.sourceforge.net>
Wed, 11 Feb 2009 19:11:36 +0000 (21:11 +0200)
committerChristos Tsantilas <chtsanti@users.sourceforge.net>
Wed, 11 Feb 2009 19:11:36 +0000 (21:11 +0200)
An access checklist required for each service set, so we need only one
AccessRule object for each adaptation service set
This patch:
  - When parses a adaptation_access line checks if an AccessRule object exist
for the service set and if yes append the access checklist to this object else
creates a new AccessRule object for this service set
  - The AccessRule constructor takes as argument now the reference service set
name (groupId)
  - The new Adaptation::FindRuleByGroupId method created. This method returns
the AccessRule object for a service set using its name (groupId)

src/adaptation/AccessRule.cc
src/adaptation/AccessRule.h
src/adaptation/Config.cc

index 1fde8c2a824f47db0b6d878537c8a2b27fc619db..d8dbd649dc26ae0b2a71bf6752540aa5bbc5a717 100644 (file)
@@ -10,7 +10,7 @@
 
 int Adaptation::AccessRule::LastId = 0;
 
-Adaptation::AccessRule::AccessRule(): id(++LastId), acl(NULL)
+Adaptation::AccessRule::AccessRule(const String &aGroupId): id(++LastId), groupId(aGroupId), acl(NULL)
 {
 }
 
@@ -22,7 +22,6 @@ Adaptation::AccessRule::~AccessRule()
 void
 Adaptation::AccessRule::parse(ConfigParser &parser)
 {
-    ConfigParser::ParseString(&groupId);
     aclParseAccessLine(parser, &acl);
 }
 
@@ -71,3 +70,15 @@ Adaptation::FindRule(const AccessRule::Id &id)
 
     return NULL;
 }
+
+Adaptation::AccessRule *
+Adaptation::FindRuleByGroupId(const String &groupId)
+{
+    typedef AccessRules::iterator ARI;
+    for (ARI i = AllRules().begin(); i != AllRules().end(); ++i) {
+        if ((*i)->groupId == groupId)
+            return *i;
+    }
+
+    return NULL;
+}
index 6924451c58b21d0171d8b1a0f4d135a9b7256d43..13386fe92e573251424b0fedf05cfde30726fb45 100644 (file)
@@ -15,7 +15,7 @@ namespace Adaptation
 class AccessRule
 {
 public:
-    AccessRule();
+    AccessRule(const String &groupId);
     ~AccessRule();
 
     void parse(ConfigParser &parser);
@@ -37,6 +37,7 @@ private:
 typedef Vector<Adaptation::AccessRule*> AccessRules;
 extern AccessRules &AllRules();
 extern AccessRule *FindRule(const AccessRule::Id &id);
+extern AccessRule *FindRuleByGroupId(const String &groupId);
 
 } // namespace Adaptation
 
index ce1fb7c5055ace1a64fdbefc1efcb246419b57ce..bb3f7cc86ce10134f4836852d69016047292c302 100644 (file)
@@ -147,7 +147,12 @@ Adaptation::Config::DumpServiceSet(StoreEntry *entry, const char *name)
 void
 Adaptation::Config::ParseAccess(ConfigParser &parser)
 {
-    AccessRule *r = new AccessRule;
+    String groupId;
+    ConfigParser::ParseString(&groupId);
+    AccessRule *r;
+    if (!(r=FindRuleByGroupId(groupId)))
+       r = new AccessRule(groupId);
+
     r->parse(parser);
     AllRules().push_back(r);
 }