From d9fac60990a817c7ef7f1a7beef90dc319bf299b Mon Sep 17 00:00:00 2001 From: "rvargas@google.com" Date: Wed, 10 Jun 2009 23:57:07 +0000 Subject: Disk cache: Avoid recursion when trimming entries. TrimCacheV2() calls EvictEntry() to move a given entry to the "deleted" list. EvictEntry() deletes the actual data, and that may end up calling ModifyStorageSize() and TrimCacheV2() again. BUG=b/1909376 TEST=none Review URL: http://codereview.chromium.org/121002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18115 0039d316-1c4b-4281-b951-d872f2087c98 --- net/disk_cache/eviction.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'net/disk_cache/eviction.cc') diff --git a/net/disk_cache/eviction.cc b/net/disk_cache/eviction.cc index cae5702..f4e74b2 100644 --- a/net/disk_cache/eviction.cc +++ b/net/disk_cache/eviction.cc @@ -65,6 +65,7 @@ void Eviction::Init(BackendImpl* backend) { max_size_ = LowWaterAdjust(backend_->max_size_); new_eviction_ = backend->new_eviction_; first_trim_ = true; + trimming_ = false; } void Eviction::TrimCache(bool empty) { @@ -72,9 +73,10 @@ void Eviction::TrimCache(bool empty) { return TrimCacheV2(empty); Trace("*** Trim Cache ***"); - if (backend_->disabled_) + if (backend_->disabled_ || trimming_) return; + trimming_ = true; Time start = Time::Now(); Rankings::ScopedRankingsBlock node(rankings_); Rankings::ScopedRankingsBlock next(rankings_, @@ -103,6 +105,7 @@ void Eviction::TrimCache(bool empty) { } CACHE_UMA(AGE_MS, "TotalTrimTime", 0, start); + trimming_ = false; Trace("*** Trim Cache end ***"); return; } @@ -204,9 +207,10 @@ bool Eviction::EvictEntry(CacheRankingsBlock* node, bool empty) { void Eviction::TrimCacheV2(bool empty) { Trace("*** Trim Cache ***"); - if (backend_->disabled_) + if (backend_->disabled_ || trimming_) return; + trimming_ = true; Time start = Time::Now(); const int kListsToSearch = 3; @@ -274,6 +278,7 @@ void Eviction::TrimCacheV2(bool empty) { CACHE_UMA(AGE_MS, "TotalTrimTime", 0, start); Trace("*** Trim Cache end ***"); + trimming_ = false; return; } -- cgit v1.1