From: Christos Tsantilas Date: Wed, 11 Feb 2009 19:11:36 +0000 (+0200) Subject: bug 2591: adaptation_access does not work X-Git-Tag: SQUID_3_2_0_1~1198 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=287bbe9a2b1fd5f6174f1b6ea4fca78c7c29ff3d;p=thirdparty%2Fsquid.git bug 2591: adaptation_access does not work 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) --- diff --git a/src/adaptation/AccessRule.cc b/src/adaptation/AccessRule.cc index 1fde8c2a82..d8dbd649dc 100644 --- a/src/adaptation/AccessRule.cc +++ b/src/adaptation/AccessRule.cc @@ -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; +} diff --git a/src/adaptation/AccessRule.h b/src/adaptation/AccessRule.h index 6924451c58..13386fe92e 100644 --- a/src/adaptation/AccessRule.h +++ b/src/adaptation/AccessRule.h @@ -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 AccessRules; extern AccessRules &AllRules(); extern AccessRule *FindRule(const AccessRule::Id &id); +extern AccessRule *FindRuleByGroupId(const String &groupId); } // namespace Adaptation diff --git a/src/adaptation/Config.cc b/src/adaptation/Config.cc index ce1fb7c505..bb3f7cc86c 100644 --- a/src/adaptation/Config.cc +++ b/src/adaptation/Config.cc @@ -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); }