summaryrefslogtreecommitdiffstats
path: root/net/disk_cache/entry_impl.cc
diff options
context:
space:
mode:
authorrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-07 19:47:08 +0000
committerrvargas@google.com <rvargas@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-07 19:47:08 +0000
commitc4c32fd86f36a5d282424eb3a4876f0601f8f097 (patch)
tree580af26d6d69af57f7b1c63b9fbb97fc42ef1877 /net/disk_cache/entry_impl.cc
parenta5624da1a85ae1e2785d8534018329e5a144e1fc (diff)
downloadchromium_src-c4c32fd86f36a5d282424eb3a4876f0601f8f097.zip
chromium_src-c4c32fd86f36a5d282424eb3a4876f0601f8f097.tar.gz
chromium_src-c4c32fd86f36a5d282424eb3a4876f0601f8f097.tar.bz2
Disk cache: Keep a map of all open entries.
We still have a few crashes when for some reason we believe an entry is not dirty and we follow the pointer stored by its rankings node only to crash while accessing the memory. I have no explanation to why the dirty id matches the current one (a page boundary issue maybe?), but having a map with all open entries solves the issue of having to follow pointers from disk. BUG=15596, b/1120346 TEST=unittests Review URL: http://codereview.chromium.org/149218 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20067 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/disk_cache/entry_impl.cc')
-rw-r--r--net/disk_cache/entry_impl.cc33
1 files changed, 13 insertions, 20 deletions
diff --git a/net/disk_cache/entry_impl.cc b/net/disk_cache/entry_impl.cc
index 0c8ee87..4c17cbb 100644
--- a/net/disk_cache/entry_impl.cc
+++ b/net/disk_cache/entry_impl.cc
@@ -128,7 +128,7 @@ EntryImpl::~EntryImpl() {
}
}
- backend_->CacheEntryDestroyed();
+ backend_->CacheEntryDestroyed(entry_.address());
}
void EntryImpl::Doom() {
@@ -506,34 +506,27 @@ bool EntryImpl::LoadNodeAddress() {
return node_.Load();
}
-EntryImpl* EntryImpl::Update(EntryImpl* entry) {
- DCHECK(entry->rankings()->HasData());
+bool EntryImpl::Update() {
+ DCHECK(node_.HasData());
- RankingsNode* rankings = entry->rankings()->Data();
+ RankingsNode* rankings = node_.Data();
if (rankings->pointer) {
- // Already in memory. Prevent clearing the dirty flag on the destructor.
- rankings->dirty = 0;
- EntryImpl* real_node = reinterpret_cast<EntryImpl*>(rankings->pointer);
- real_node->AddRef();
- entry->Release();
- return real_node;
+ // Nothing to do here, the entry was in memory.
+ DCHECK(rankings->pointer == this);
} else {
- rankings->dirty = entry->backend_->GetCurrentEntryId();
- rankings->pointer = entry;
- if (!entry->rankings()->Store()) {
- entry->Release();
- return NULL;
- }
- return entry;
+ rankings->dirty = backend_->GetCurrentEntryId();
+ rankings->pointer = this;
+ if (!node_.Store())
+ return false;
}
+ return true;
}
bool EntryImpl::IsDirty(int32 current_id) {
DCHECK(node_.HasData());
// We are checking if the entry is valid or not. If there is a pointer here,
- // |dirty| has to be the id of the cache that is using the entry (the one
- // that created the pointer), 0 is not a valid id.
- if (node_.Data()->pointer && !node_.Data()->dirty)
+ // we should not be checking the entry.
+ if (node_.Data()->pointer)
return true;
return node_.Data()->dirty && current_id != node_.Data()->dirty;