aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2008-01-16 18:09:27 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2008-01-16 18:09:27 +0000
commit243f537dd8a3eb70327695fea251a47ae8d42f40 (patch)
treee9e8fffe761a2f520121a36a6641ff9850583f1c
parent43eaa077edf7825e404599593522acd5f41aa88d (diff)
downloadpaludis-243f537dd8a3eb70327695fea251a47ae8d42f40.tar.gz
paludis-243f537dd8a3eb70327695fea251a47ae8d42f40.tar.xz
Be thread-safe.
-rw-r--r--paludis/repositories/e/qa/restrict_key.cc37
1 files changed, 23 insertions, 14 deletions
diff --git a/paludis/repositories/e/qa/restrict_key.cc b/paludis/repositories/e/qa/restrict_key.cc
index 9f8f54e..d1ee362 100644
--- a/paludis/repositories/e/qa/restrict_key.cc
+++ b/paludis/repositories/e/qa/restrict_key.cc
@@ -22,6 +22,7 @@
#include <paludis/metadata_key.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/log.hh>
+#include <paludis/util/instantiation_policy-impl.hh>
#include <paludis/name.hh>
#include <paludis/dep_spec.hh>
#include <paludis/package_id.hh>
@@ -33,6 +34,25 @@ using namespace paludis::erepository;
namespace
{
+ struct AllowedRestricts :
+ InstantiationPolicy<AllowedRestricts, instantiation_method::SingletonTag>
+ {
+ std::set<std::string> allowed_restricts;
+
+ AllowedRestricts()
+ {
+ allowed_restricts.insert("fetch");
+ allowed_restricts.insert("mirror");
+ allowed_restricts.insert("nomirror");
+ allowed_restricts.insert("primaryuri");
+ allowed_restricts.insert("nostrip");
+ allowed_restricts.insert("strip");
+ allowed_restricts.insert("sandbox");
+ allowed_restricts.insert("userpriv");
+ allowed_restricts.insert("test");
+ }
+ };
+
struct RestrictChecker :
ConstVisitor<RestrictSpecTree>,
ConstVisitor<RestrictSpecTree>::VisitConstSequence<RestrictChecker, AllDepSpec>,
@@ -41,6 +61,8 @@ namespace
using ConstVisitor<RestrictSpecTree>::VisitConstSequence<RestrictChecker, UseDepSpec>::visit_sequence;
using ConstVisitor<RestrictSpecTree>::VisitConstSequence<RestrictChecker, AllDepSpec>::visit_sequence;
+ const std::set<std::string> & allowed_restricts;
+
const tr1::shared_ptr<const MetadataKey> & key;
const FSEntry entry;
QAReporter & reporter;
@@ -53,6 +75,7 @@ namespace
QAReporter & r,
const tr1::shared_ptr<const PackageID> & i,
const std::string & n) :
+ allowed_restricts(AllowedRestricts::get_instance()->allowed_restricts),
key(k),
entry(f),
reporter(r),
@@ -63,20 +86,6 @@ namespace
void visit_leaf(const PlainTextDepSpec & t)
{
- static std::set<std::string> allowed_restricts;
- if (allowed_restricts.empty())
- {
- allowed_restricts.insert("fetch");
- allowed_restricts.insert("mirror");
- allowed_restricts.insert("nomirror");
- allowed_restricts.insert("primaryuri");
- allowed_restricts.insert("nostrip");
- allowed_restricts.insert("strip");
- allowed_restricts.insert("sandbox");
- allowed_restricts.insert("userpriv");
- allowed_restricts.insert("test");
- }
-
if (allowed_restricts.end() == allowed_restricts.find(t.text()))
reporter.message(QAMessage(entry, qaml_normal, name,
"Unrecognised value '" + t.text() + "' in '" + key->raw_name() + "'")