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

Unified Diff: sync/syncable/directory.cc

Issue 10821121: sync: Attempt to recover from directory corruption (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes Created 8 years, 5 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
Index: sync/syncable/directory.cc
diff --git a/sync/syncable/directory.cc b/sync/syncable/directory.cc
index d30c0d5542e77b291e066a89d8a2f3d3ade86805..9348338925f114f2e8052c7323fc4f30bebf0255 100644
--- a/sync/syncable/directory.cc
+++ b/sync/syncable/directory.cc
@@ -36,41 +36,6 @@ void InitializeIndexEntry(EntryKernel* entry,
}
}
-// This function checks to see if the given list of Metahandles has any nodes
-// whose PREV_ID, PARENT_ID or NEXT_ID values refer to ID values that do not
-// actually exist. Returns true on success.
-//
-// This function is "Unsafe" because it does not attempt to acquire any locks
-// that may be protecting this list that gets passed in. The caller is
-// responsible for ensuring that no one modifies this list while the function is
-// running.
-bool VerifyReferenceIntegrityUnsafe(const syncable::MetahandlesIndex &index) {
- TRACE_EVENT0("sync", "SyncDatabaseIntegrityCheck");
- using namespace syncable;
- typedef base::hash_set<std::string> IdsSet;
-
- IdsSet ids_set;
- bool is_ok = true;
-
- for (MetahandlesIndex::const_iterator it = index.begin();
- it != index.end(); ++it) {
- EntryKernel* entry = *it;
- bool is_duplicate_id = !(ids_set.insert(entry->ref(ID).value()).second);
- is_ok = is_ok && !is_duplicate_id;
- }
-
- IdsSet::iterator end = ids_set.end();
- for (MetahandlesIndex::const_iterator it = index.begin();
- it != index.end(); ++it) {
- EntryKernel* entry = *it;
- bool prev_exists = (ids_set.find(entry->ref(PREV_ID).value()) != end);
- bool parent_exists = (ids_set.find(entry->ref(PARENT_ID).value()) != end);
- bool next_exists = (ids_set.find(entry->ref(NEXT_ID).value()) != end);
- is_ok = is_ok && prev_exists && parent_exists && next_exists;
- }
- return is_ok;
-}
-
}
// static
@@ -236,9 +201,6 @@ DirOpenResult Directory::OpenImpl(
if (OPENED != result)
return result;
- if (!VerifyReferenceIntegrityUnsafe(metas_bucket))
- return FAILED_LOGICAL_CORRUPTION;
-
kernel_ = new Kernel(name, info, delegate, transaction_observer);
kernel_->metahandles_index->swap(metas_bucket);
InitializeIndices();

Powered by Google App Engine
This is Rietveld 408576698