aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar David Leverton <levertond@googlemail.com> 2007-07-24 21:44:44 +0000
committerAvatar David Leverton <levertond@googlemail.com> 2007-07-24 21:44:44 +0000
commit634cca14ddefdb1efecc675ad76ead9a334dc5bb (patch)
tree26b57fa6441fe5d5c0cd0ad6df8c9fc93a703b9c
parent4ea049085d61e47f4c5673958dc8ca2a972a5eda (diff)
downloadpaludis-634cca14ddefdb1efecc675ad76ead9a334dc5bb.tar.gz
paludis-634cca14ddefdb1efecc675ad76ead9a334dc5bb.tar.xz
Don't destroy mutexes that might be in use.
-rw-r--r--paludis/repositories/e/e_repository.cc41
-rw-r--r--paludis/repositories/e/vdb_repository.cc47
-rw-r--r--paludis/repositories/gems/gems_repository.cc25
-rw-r--r--paludis/repositories/gems/installed_gems_repository.cc26
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.cc9
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.cc15
6 files changed, 89 insertions, 74 deletions
diff --git a/paludis/repositories/e/e_repository.cc b/paludis/repositories/e/e_repository.cc
index 4337cf9..12289da 100644
--- a/paludis/repositories/e/e_repository.cc
+++ b/paludis/repositories/e/e_repository.cc
@@ -108,42 +108,48 @@ namespace paludis
template <>
struct Implementation<ERepository>
{
+ struct Mutexes
+ {
+ Mutex repo_mask_mutex;
+ Mutex arch_flags_mutex;
+ Mutex mirrors_mutex;
+ Mutex profiles_desc_mutex;
+ Mutex use_desc_mutex;
+ Mutex profile_ptr_mutex;
+ Mutex news_ptr_mutex;
+ };
+
ERepository * const repo;
const ERepositoryParams params;
+ const tr1::shared_ptr<Mutexes> mutexes;
+
tr1::shared_ptr<RepositoryNameCache> names_cache;
- mutable Mutex repo_mask_mutex;
mutable RepositoryMaskMap repo_mask;
mutable bool has_repo_mask;
const std::map<QualifiedPackageName, QualifiedPackageName> provide_map;
- mutable Mutex arch_flags_mutex;
mutable tr1::shared_ptr<UseFlagNameSet> arch_flags;
- mutable Mutex mirrors_mutex;
mutable bool has_mirrors;
mutable MirrorMap mirrors;
- mutable Mutex profiles_desc_mutex;
mutable bool has_profiles_desc;
mutable ProfilesDesc profiles_desc;
- mutable Mutex use_desc_mutex;
mutable std::list<tr1::shared_ptr<UseDesc> > use_desc;
- mutable Mutex profile_ptr_mutex;
mutable tr1::shared_ptr<ERepositoryProfile> profile_ptr;
- mutable Mutex news_ptr_mutex;
mutable tr1::shared_ptr<ERepositoryNews> news_ptr;
mutable tr1::shared_ptr<ERepositorySets> sets_ptr;
mutable tr1::shared_ptr<erepository::ERepositoryEntries> entries_ptr;
mutable tr1::shared_ptr<erepository::Layout> layout;
- Implementation(ERepository * const, const ERepositoryParams &);
+ Implementation(ERepository * const, const ERepositoryParams &, tr1::shared_ptr<Mutexes> = make_shared_ptr(new Mutexes));
~Implementation();
void need_profiles() const;
@@ -151,9 +157,10 @@ namespace paludis
};
Implementation<ERepository>::Implementation(ERepository * const r,
- const ERepositoryParams & p) :
+ const ERepositoryParams & p, tr1::shared_ptr<Mutexes> m) :
repo(r),
params(p),
+ mutexes(m),
names_cache(new RepositoryNameCache(p.names_cache, r)),
has_repo_mask(false),
has_mirrors(false),
@@ -175,7 +182,7 @@ namespace paludis
void
Implementation<ERepository>::need_profiles() const
{
- Lock l(profile_ptr_mutex);
+ Lock l(mutexes->profile_ptr_mutex);
if (profile_ptr)
return;
@@ -189,7 +196,7 @@ namespace paludis
void
Implementation<ERepository>::need_profiles_desc() const
{
- Lock l(profiles_desc_mutex);
+ Lock l(mutexes->profiles_desc_mutex);
if (has_profiles_desc)
return;
@@ -369,7 +376,7 @@ ERepository::do_package_ids(const QualifiedPackageName & n) const
bool
ERepository::repository_masked(const PackageID & id) const
{
- Lock l(_imp->repo_mask_mutex);
+ Lock l(_imp->mutexes->repo_mask_mutex);
if (! _imp->has_repo_mask)
{
@@ -447,7 +454,7 @@ ERepository::do_query_use_force(const UseFlagName & u, const PackageID & e) cons
tr1::shared_ptr<const UseFlagNameSet>
ERepository::do_arch_flags() const
{
- Lock l(_imp->arch_flags_mutex);
+ Lock l(_imp->mutexes->arch_flags_mutex);
if (! _imp->arch_flags)
{
Context context("When loading arch list:");
@@ -498,7 +505,7 @@ ERepository::do_license_exists(const std::string & license) const
void
ERepository::need_mirrors() const
{
- Lock l(_imp->mirrors_mutex);
+ Lock l(_imp->mutexes->mirrors_mutex);
if (! _imp->has_mirrors)
{
@@ -601,7 +608,7 @@ ERepository::do_sync() const
void
ERepository::invalidate()
{
- _imp.reset(new Implementation<ERepository>(this, _imp->params));
+ _imp.reset(new Implementation<ERepository>(this, _imp->params, _imp->mutexes));
}
void
@@ -618,7 +625,7 @@ ERepository::invalidate_masks()
void
ERepository::update_news() const
{
- Lock l(_imp->news_ptr_mutex);
+ Lock l(_imp->mutexes->news_ptr_mutex);
if (! _imp->news_ptr)
_imp->news_ptr.reset(new ERepositoryNews(_imp->params.environment, this, _imp->params));
@@ -923,7 +930,7 @@ std::string
ERepository::do_describe_use_flag(const UseFlagName & f,
const PackageID & e) const
{
- Lock l(_imp->use_desc_mutex);
+ Lock l(_imp->mutexes->use_desc_mutex);
if (_imp->use_desc.empty())
{
diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc
index be49847..658eac0 100644
--- a/paludis/repositories/e/vdb_repository.cc
+++ b/paludis/repositories/e/vdb_repository.cc
@@ -100,7 +100,7 @@ namespace paludis
{
VDBRepositoryParams params;
- mutable Mutex big_nasty_mutex;
+ const tr1::shared_ptr<Mutex> big_nasty_mutex;
mutable CategoryMap categories;
mutable bool has_category_names;
@@ -109,13 +109,14 @@ namespace paludis
mutable tr1::shared_ptr<RepositoryProvidesInterface::ProvidesSequence> provides;
tr1::shared_ptr<RepositoryNameCache> names_cache;
- Implementation(const VDBRepository * const, const VDBRepositoryParams &);
+ Implementation(const VDBRepository * const, const VDBRepositoryParams &, tr1::shared_ptr<Mutex> = make_shared_ptr(new Mutex));
~Implementation();
};
Implementation<VDBRepository>::Implementation(const VDBRepository * const r,
- const VDBRepositoryParams & p) :
+ const VDBRepositoryParams & p, tr1::shared_ptr<Mutex> m) :
params(p),
+ big_nasty_mutex(m),
has_category_names(false),
names_cache(new RepositoryNameCache(p.names_cache, r))
{
@@ -168,7 +169,7 @@ VDBRepository::~VDBRepository()
bool
VDBRepository::do_has_category_named(const CategoryNamePart & c) const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
Context context("When checking for category '" + stringify(c) +
"' in " + stringify(name()) + ":");
@@ -180,7 +181,7 @@ VDBRepository::do_has_category_named(const CategoryNamePart & c) const
bool
VDBRepository::do_has_package_named(const QualifiedPackageName & q) const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
Context context("When checking for package '" + stringify(q) +
"' in " + stringify(name()) + ":");
@@ -199,7 +200,7 @@ VDBRepository::do_has_package_named(const QualifiedPackageName & q) const
tr1::shared_ptr<const CategoryNamePartSet>
VDBRepository::do_category_names() const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
Context context("When fetching category names in " + stringify(name()) + ":");
@@ -217,7 +218,7 @@ VDBRepository::do_category_names() const
tr1::shared_ptr<const QualifiedPackageNameSet>
VDBRepository::do_package_names(const CategoryNamePart & c) const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
Context context("When fetching package names in category '" + stringify(c)
+ "' in " + stringify(name()) + ":");
@@ -236,7 +237,7 @@ VDBRepository::do_package_names(const CategoryNamePart & c) const
tr1::shared_ptr<const PackageIDSequence>
VDBRepository::do_package_ids(const QualifiedPackageName & n) const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
Context context("When fetching versions of '" + stringify(n) + "' in "
+ stringify(name()) + ":");
@@ -256,7 +257,7 @@ VDBRepository::do_package_ids(const QualifiedPackageName & n) const
UseFlagState
VDBRepository::do_query_use(const UseFlagName & f, const PackageID & e) const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
if (! e.use_key())
return use_unspecified;
@@ -547,9 +548,9 @@ VDBRepository::sets_list() const
void
VDBRepository::invalidate()
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
- _imp.reset(new Implementation<VDBRepository>(this, _imp->params));
+ _imp.reset(new Implementation<VDBRepository>(this, _imp->params, _imp->big_nasty_mutex));
}
void
@@ -560,7 +561,7 @@ VDBRepository::invalidate_masks()
void
VDBRepository::add_string_to_world(const std::string & n) const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
Context context("When adding '" + n + "' to world file '" + stringify(_imp->params.world) + "':");
@@ -588,7 +589,7 @@ VDBRepository::add_string_to_world(const std::string & n) const
void
VDBRepository::remove_string_from_world(const std::string & n) const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
Context context("When removing '" + n + "' from world file '" + stringify(_imp->params.world) + "':");
@@ -672,7 +673,7 @@ VDBRepository::get_environment_variable(
tr1::shared_ptr<const RepositoryProvidesInterface::ProvidesSequence>
VDBRepository::provided_packages() const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
if (_imp->provides)
return _imp->provides;
@@ -710,7 +711,7 @@ VDBRepository::do_use_expand_hidden_prefixes() const
bool
VDBRepository::load_provided_using_cache() const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
if (_imp->params.provides_cache == FSEntry("/var/empty"))
return false;
@@ -785,7 +786,7 @@ VDBRepository::load_provided_using_cache() const
void
VDBRepository::load_provided_the_slow_way() const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
using namespace tr1::placeholders;
@@ -853,7 +854,7 @@ VDBRepository::load_provided_the_slow_way() const
void
VDBRepository::regenerate_cache() const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
regenerate_provides_cache();
_imp->names_cache->regenerate_cache();
@@ -862,7 +863,7 @@ VDBRepository::regenerate_cache() const
void
VDBRepository::regenerate_provides_cache() const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
using namespace tr1::placeholders;
@@ -916,7 +917,7 @@ VDBRepository::regenerate_provides_cache() const
tr1::shared_ptr<const CategoryNamePartSet>
VDBRepository::do_category_names_containing_package(const PackageNamePart & p) const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
if (! _imp->names_cache->usable())
return Repository::do_category_names_containing_package(p);
@@ -1058,7 +1059,7 @@ VDBRepository::perform_hook(const Hook & hook) const
void
VDBRepository::need_category_names() const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
if (_imp->has_category_names)
return;
@@ -1084,7 +1085,7 @@ VDBRepository::need_category_names() const
void
VDBRepository::need_package_ids(const CategoryNamePart & c) const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
if (_imp->categories[c])
return;
@@ -1123,7 +1124,7 @@ VDBRepository::need_package_ids(const CategoryNamePart & c) const
const tr1::shared_ptr<const ERepositoryID>
VDBRepository::make_id(const QualifiedPackageName & q, const VersionSpec & v, const FSEntry & f) const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
Context context("When creating ID for '" + stringify(q) + "-" + stringify(v) + "' from '" + stringify(f) + "':");
@@ -1134,7 +1135,7 @@ VDBRepository::make_id(const QualifiedPackageName & q, const VersionSpec & v, co
const tr1::shared_ptr<const ERepositoryID>
VDBRepository::package_id_if_exists(const QualifiedPackageName & q, const VersionSpec & v) const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
if (! has_package_named(q))
return tr1::shared_ptr<const ERepositoryID>();
diff --git a/paludis/repositories/gems/gems_repository.cc b/paludis/repositories/gems/gems_repository.cc
index 3e5968b..78df2a8 100644
--- a/paludis/repositories/gems/gems_repository.cc
+++ b/paludis/repositories/gems/gems_repository.cc
@@ -46,7 +46,7 @@ namespace paludis
{
const gems::RepositoryParams params;
- mutable Mutex big_nasty_mutex;
+ const tr1::shared_ptr<Mutex> big_nasty_mutex;
mutable tr1::shared_ptr<const CategoryNamePartSet> category_names;
mutable MakeHashedMap<CategoryNamePart, tr1::shared_ptr<const QualifiedPackageNameSet> >::Type package_names;
@@ -55,8 +55,9 @@ namespace paludis
mutable bool has_category_names;
mutable bool has_ids;
- Implementation(const gems::RepositoryParams p) :
+ Implementation(const gems::RepositoryParams p, tr1::shared_ptr<Mutex> m = make_shared_ptr(new Mutex)) :
params(p),
+ big_nasty_mutex(m),
has_category_names(false),
has_ids(false)
{
@@ -104,15 +105,15 @@ GemsRepository::~GemsRepository()
void
GemsRepository::invalidate()
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
- _imp.reset(new Implementation<GemsRepository>(_imp->params));
+ _imp.reset(new Implementation<GemsRepository>(_imp->params, _imp->big_nasty_mutex));
}
void
GemsRepository::invalidate_masks()
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
for (MakeHashedMap<QualifiedPackageName, tr1::shared_ptr<PackageIDSequence> >::Type::iterator it(_imp->ids.begin()), it_end(_imp->ids.end());
it_end != it; ++it)
@@ -124,7 +125,7 @@ GemsRepository::invalidate_masks()
bool
GemsRepository::do_has_category_named(const CategoryNamePart & c) const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
need_category_names();
return _imp->category_names->end() != _imp->category_names->find(c);
@@ -133,7 +134,7 @@ GemsRepository::do_has_category_named(const CategoryNamePart & c) const
bool
GemsRepository::do_has_package_named(const QualifiedPackageName & q) const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
if (! do_has_category_named(q.category))
return false;
@@ -145,7 +146,7 @@ GemsRepository::do_has_package_named(const QualifiedPackageName & q) const
tr1::shared_ptr<const CategoryNamePartSet>
GemsRepository::do_category_names() const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
need_category_names();
return _imp->category_names;
@@ -154,7 +155,7 @@ GemsRepository::do_category_names() const
tr1::shared_ptr<const QualifiedPackageNameSet>
GemsRepository::do_package_names(const CategoryNamePart & c) const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
if (! has_category_named(c))
return make_shared_ptr(new QualifiedPackageNameSet);
@@ -171,7 +172,7 @@ GemsRepository::do_package_names(const CategoryNamePart & c) const
tr1::shared_ptr<const PackageIDSequence>
GemsRepository::do_package_ids(const QualifiedPackageName & q) const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
if (! has_package_named(q))
return make_shared_ptr(new PackageIDSequence);
@@ -189,7 +190,7 @@ GemsRepository::do_package_ids(const QualifiedPackageName & q) const
void
GemsRepository::need_category_names() const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
if (_imp->has_category_names)
return;
@@ -204,7 +205,7 @@ GemsRepository::need_category_names() const
void
GemsRepository::need_ids() const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
if (_imp->has_ids)
return;
diff --git a/paludis/repositories/gems/installed_gems_repository.cc b/paludis/repositories/gems/installed_gems_repository.cc
index 60d4f10..b76d7a5 100644
--- a/paludis/repositories/gems/installed_gems_repository.cc
+++ b/paludis/repositories/gems/installed_gems_repository.cc
@@ -52,7 +52,7 @@ namespace paludis
template <>
struct Implementation<InstalledGemsRepository>
{
- mutable Mutex big_nasty_mutex;
+ const tr1::shared_ptr<Mutex> big_nasty_mutex;
const gems::InstalledRepositoryParams params;
@@ -63,7 +63,9 @@ namespace paludis
mutable bool has_category_names;
mutable bool has_ids;
- Implementation(const gems::InstalledRepositoryParams p) :
+ Implementation(const gems::InstalledRepositoryParams p,
+ tr1::shared_ptr<Mutex> m = make_shared_ptr(new Mutex)) :
+ big_nasty_mutex(m),
params(p),
has_category_names(false),
has_ids(false)
@@ -109,9 +111,9 @@ InstalledGemsRepository::~InstalledGemsRepository()
void
InstalledGemsRepository::invalidate()
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
- _imp.reset(new Implementation<InstalledGemsRepository>(_imp->params));
+ _imp.reset(new Implementation<InstalledGemsRepository>(_imp->params, _imp->big_nasty_mutex));
}
void
@@ -122,7 +124,7 @@ InstalledGemsRepository::invalidate_masks()
bool
InstalledGemsRepository::do_has_category_named(const CategoryNamePart & c) const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
need_category_names();
return _imp->category_names->end() != _imp->category_names->find(c);
@@ -131,7 +133,7 @@ InstalledGemsRepository::do_has_category_named(const CategoryNamePart & c) const
bool
InstalledGemsRepository::do_has_package_named(const QualifiedPackageName & q) const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
if (! do_has_category_named(q.category))
return false;
@@ -143,7 +145,7 @@ InstalledGemsRepository::do_has_package_named(const QualifiedPackageName & q) co
tr1::shared_ptr<const CategoryNamePartSet>
InstalledGemsRepository::do_category_names() const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
need_category_names();
return _imp->category_names;
@@ -152,7 +154,7 @@ InstalledGemsRepository::do_category_names() const
tr1::shared_ptr<const QualifiedPackageNameSet>
InstalledGemsRepository::do_package_names(const CategoryNamePart & c) const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
if (! has_category_named(c))
return make_shared_ptr(new QualifiedPackageNameSet);
@@ -169,7 +171,7 @@ InstalledGemsRepository::do_package_names(const CategoryNamePart & c) const
tr1::shared_ptr<const PackageIDSequence>
InstalledGemsRepository::do_package_ids(const QualifiedPackageName & q) const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
if (! has_package_named(q))
return make_shared_ptr(new PackageIDSequence);
@@ -186,7 +188,7 @@ InstalledGemsRepository::do_package_ids(const QualifiedPackageName & q) const
void
InstalledGemsRepository::need_category_names() const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
if (_imp->has_category_names)
return;
@@ -201,7 +203,7 @@ InstalledGemsRepository::need_category_names() const
void
InstalledGemsRepository::need_ids() const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
if (_imp->has_ids)
return;
@@ -243,7 +245,7 @@ InstalledGemsRepository::need_ids() const
bool
InstalledGemsRepository::is_suitable_destination_for(const PackageID & e) const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
std::string f(e.repository()->format());
return f == "gems";
diff --git a/paludis/repositories/virtuals/installed_virtuals_repository.cc b/paludis/repositories/virtuals/installed_virtuals_repository.cc
index 1fe1c99..47a2515 100644
--- a/paludis/repositories/virtuals/installed_virtuals_repository.cc
+++ b/paludis/repositories/virtuals/installed_virtuals_repository.cc
@@ -54,13 +54,14 @@ namespace paludis
const Environment * const env;
const FSEntry root;
- mutable Mutex ids_mutex;
+ const tr1::shared_ptr<Mutex> ids_mutex;
mutable IDMap ids;
mutable bool has_ids;
- Implementation(const Environment * const e, const FSEntry & r) :
+ Implementation(const Environment * const e, const FSEntry & r, tr1::shared_ptr<Mutex> m = make_shared_ptr(new Mutex)) :
env(e),
root(r),
+ ids_mutex(m),
has_ids(false)
{
}
@@ -134,7 +135,7 @@ InstalledVirtualsRepository::~InstalledVirtualsRepository()
void
InstalledVirtualsRepository::need_ids() const
{
- Lock l(_imp->ids_mutex);
+ Lock l(*_imp->ids_mutex);
if (_imp->has_ids)
return;
@@ -240,7 +241,7 @@ InstalledVirtualsRepository::do_has_category_named(const CategoryNamePart & c) c
void
InstalledVirtualsRepository::invalidate()
{
- _imp.reset(new Implementation<InstalledVirtualsRepository>(_imp->env, _imp->root));
+ _imp.reset(new Implementation<InstalledVirtualsRepository>(_imp->env, _imp->root, _imp->ids_mutex));
}
void
diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc
index 2d873a7..f1f93ee 100644
--- a/paludis/repositories/virtuals/virtuals_repository.cc
+++ b/paludis/repositories/virtuals/virtuals_repository.cc
@@ -56,7 +56,7 @@ namespace paludis
{
const Environment * const env;
- mutable Mutex big_nasty_mutex;
+ const tr1::shared_ptr<Mutex> big_nasty_mutex;
mutable std::vector<std::pair<QualifiedPackageName, tr1::shared_ptr<const PackageDepSpec> > > names;
mutable bool has_names;
@@ -64,8 +64,9 @@ namespace paludis
mutable IDMap ids;
mutable bool has_ids;
- Implementation(const Environment * const e) :
+ Implementation(const Environment * const e, tr1::shared_ptr<Mutex> m = make_shared_ptr(new Mutex)) :
env(e),
+ big_nasty_mutex(m),
has_names(false),
has_ids(false)
{
@@ -130,7 +131,7 @@ VirtualsRepository::~VirtualsRepository()
void
VirtualsRepository::need_names() const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
if (_imp->has_names)
return;
@@ -191,7 +192,7 @@ VirtualsRepository::need_names() const
void
VirtualsRepository::need_ids() const
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
if (_imp->has_ids)
return;
@@ -305,13 +306,15 @@ VirtualsRepository::do_has_category_named(const CategoryNamePart & c) const
void
VirtualsRepository::invalidate()
{
- _imp.reset(new Implementation<VirtualsRepository>(_imp->env));
+ Lock l(*_imp->big_nasty_mutex);
+
+ _imp.reset(new Implementation<VirtualsRepository>(_imp->env, _imp->big_nasty_mutex));
}
void
VirtualsRepository::invalidate_masks()
{
- Lock l(_imp->big_nasty_mutex);
+ Lock l(*_imp->big_nasty_mutex);
for (IDMap::iterator it(_imp->ids.begin()), it_end(_imp->ids.end()); it_end != it; ++it)
for (PackageIDSequence::Iterator it2(it->second->begin()), it2_end(it->second->end());