Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(161)

Unified Diff: net/tools/dump_cache/dump_files.cc

Issue 6292011: Disk cache: Prevent obscure file corruption and deal... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« net/disk_cache/eviction.cc ('K') | « net/disk_cache/eviction.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/tools/dump_cache/dump_files.cc
===================================================================
--- net/tools/dump_cache/dump_files.cc (revision 71365)
+++ net/tools/dump_cache/dump_files.cc (working copy)
@@ -6,6 +6,7 @@
// to the actual files (they still may change if an error is detected on the
// files).
+#include <set>
#include <stdio.h>
#include <string>
@@ -67,6 +68,7 @@
for (int i = 0; i < 5; i++) {
printf("head %d: 0x%x\n", i, header.lru.heads[i]);
printf("tail %d: 0x%x\n", i, header.lru.tails[i]);
+ printf("size %d: 0x%x\n", i, header.lru.sizes[i]);
}
printf("transaction: 0x%x\n", header.lru.transaction);
printf("operation: %d\n", header.lru.operation);
@@ -131,6 +133,7 @@
disk_cache::Index* index_;
int current_hash_;
disk_cache::CacheAddr next_addr_;
+ std::set<disk_cache::CacheAddr> dumped_entries_;
DISALLOW_COPY_AND_ASSIGN(CacheDumper);
};
@@ -154,17 +157,19 @@
}
bool CacheDumper::GetEntry(disk_cache::EntryStore* entry) {
+ if (dumped_entries_.find(next_addr_) != dumped_entries_.end()) {
+ printf("Loop detected\n");
+ next_addr_ = 0;
+ current_hash_++;
+ }
+
if (next_addr_) {
- if (LoadEntry(next_addr_, entry)) {
- next_addr_ = entry->next;
- if (!next_addr_)
- current_hash_++;
+ if (LoadEntry(next_addr_, entry))
return true;
- } else {
- printf("Unable to load entry at address 0x%x\n", next_addr_);
- next_addr_ = 0;
- current_hash_++;
- }
+
+ printf("Unable to load entry at address 0x%x\n", next_addr_);
+ next_addr_ = 0;
+ current_hash_++;
}
for (int i = current_hash_; i < index_->header.table_len; i++) {
@@ -172,14 +177,10 @@
// dumping every entry that we can find.
if (index_->table[i]) {
current_hash_ = i;
- if (LoadEntry(index_->table[i], entry)) {
- next_addr_ = entry->next;
- if (!next_addr_)
- current_hash_++;
+ if (LoadEntry(index_->table[i], entry))
return true;
- } else {
- printf("Unable to load entry at address 0x%x\n", index_->table[i]);
- }
+
+ printf("Unable to load entry at address 0x%x\n", index_->table[i]);
}
}
return false;
@@ -198,6 +199,15 @@
memcpy(entry, entry_block.Data(), sizeof(*entry));
printf("Entry at 0x%x\n", addr);
+
+ // Prepare for the next entry to load.
+ next_addr_ = entry->next;
+ if (next_addr_) {
+ dumped_entries_.insert(addr);
+ } else {
+ current_hash_++;
+ dumped_entries_.clear();
+ }
return true;
}
« net/disk_cache/eviction.cc ('K') | « net/disk_cache/eviction.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698