diff options
Diffstat (limited to 'apt-pkg/cachefile.cc')
-rw-r--r-- | apt-pkg/cachefile.cc | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/apt-pkg/cachefile.cc b/apt-pkg/cachefile.cc index a22804c36..9a1a6cfa9 100644 --- a/apt-pkg/cachefile.cc +++ b/apt-pkg/cachefile.cc @@ -35,12 +35,18 @@ #include <apti18n.h> /*}}}*/ + +struct pkgCacheFile::Private +{ + bool WithLock = false; +}; + // CacheFile::CacheFile - Constructor /*{{{*/ -pkgCacheFile::pkgCacheFile() : d(NULL), ExternOwner(false), Map(NULL), Cache(NULL), +pkgCacheFile::pkgCacheFile() : d(new Private()), ExternOwner(false), Map(NULL), Cache(NULL), DCache(NULL), SrcList(NULL), Policy(NULL) { } -pkgCacheFile::pkgCacheFile(pkgDepCache * const Owner) : d(NULL), ExternOwner(true), +pkgCacheFile::pkgCacheFile(pkgDepCache * const Owner) : d(new Private()), ExternOwner(true), Map(&Owner->GetCache().GetMap()), Cache(&Owner->GetCache()), DCache(Owner), SrcList(NULL), Policy(NULL) { @@ -59,8 +65,10 @@ pkgCacheFile::~pkgCacheFile() } delete Policy; delete SrcList; - if (ExternOwner == false) + if (d->WithLock == true) _system->UnLock(true); + + delete d; } /*}}}*/ // CacheFile::BuildCaches - Open and build the cache files /*{{{*/ @@ -97,8 +105,11 @@ bool pkgCacheFile::BuildCaches(OpProgress *Progress, bool WithLock) } if (WithLock == true) + { if (_system->Lock() == false) return false; + d->WithLock = true; + } if (_error->PendingError() == true) return false; @@ -337,7 +348,11 @@ void pkgCacheFile::Close() ExternOwner = false; delete Policy; delete SrcList; - _system->UnLock(true); + if (d->WithLock == true) + { + _system->UnLock(true); + d->WithLock = false; + } Map = NULL; DCache = NULL; |