From 95278287f4e1eeaf5d96749d6fc9bfc53fb400d0 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 10 Sep 2015 19:00:51 +0200 Subject: avoid using global PendingError to avoid failing too often too soon MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Our error reporting is historically grown into some kind of mess. A while ago I implemented stacking for the global error which is used in this commit now to wrap calls to functions which do not report (all) errors via return, so that only failures in those calls cause a failure to propergate down the chain rather than failing if anything (potentially totally unrelated) has failed at some point in the past. This way we can avoid stopping the entire acquire process just because a single source produced an error for example. It also means that after the acquire process the cache is generated – even if the acquire process had failures – as we still have the old good data around we can and should generate a cache for (again). There are probably more instances of this hiding, but all these looked like the easiest to work with and fix with reasonable (aka net-positive) effects. --- apt-pkg/srcrecords.cc | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'apt-pkg/srcrecords.cc') diff --git a/apt-pkg/srcrecords.cc b/apt-pkg/srcrecords.cc index 942f11569..53d7e604d 100644 --- a/apt-pkg/srcrecords.cc +++ b/apt-pkg/srcrecords.cc @@ -39,11 +39,14 @@ pkgSrcRecords::pkgSrcRecords(pkgSourceList &List) : d(NULL), Files(0) for (std::vector::const_iterator J = Indexes->begin(); J != Indexes->end(); ++J) { - Parser* P = (*J)->CreateSrcParser(); - if (_error->PendingError() == true) - return; - if (P != 0) - Files.push_back(P); + _error->PushToStack(); + Parser* P = (*J)->CreateSrcParser(); + bool const newError = _error->PendingError(); + _error->MergeWithStack(); + if (newError) + return; + if (P != 0) + Files.push_back(P); } } @@ -93,8 +96,6 @@ const pkgSrcRecords::Parser* pkgSrcRecords::Step() // Step to the next record, possibly switching files while ((*Current)->Step() == false) { - if (_error->PendingError() == true) - return 0; ++Current; if (Current == Files.end()) return 0; @@ -115,10 +116,6 @@ pkgSrcRecords::Parser *pkgSrcRecords::Find(const char *Package,bool const &SrcOn if(Step() == 0) return 0; - // IO error somehow - if (_error->PendingError() == true) - return 0; - // Source name hit if ((*Current)->Package() == Package) return *Current; -- cgit v1.2.3