summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authornick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-28 22:14:05 +0000
committernick@chromium.org <nick@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-28 22:14:05 +0000
commit45fffa1a3e1a22da15564fad20c20c0e545bcde3 (patch)
tree270e8929a527a883b1aaefa4d467f7ac91d0dd00
parent67e5077346cde830210611c2f00fb550d563fcd3 (diff)
downloadchromium_src-45fffa1a3e1a22da15564fad20c20c0e545bcde3.zip
chromium_src-45fffa1a3e1a22da15564fad20c20c0e545bcde3.tar.gz
chromium_src-45fffa1a3e1a22da15564fad20c20c0e545bcde3.tar.bz2
Don't acquire a database lock in syncable::DirectoryBackingStore::SaveChanges if there is nothing to save.
Patch contributed by vt (p155off@gmail.com). BUG=33367 TEST=SyncData.sqlite3-journal isn't written to every 10 seconds with sync enabled; sync_unit_tests continue to pass Review URL: http://codereview.chromium.org/558019 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37448 0039d316-1c4b-4281-b951-d872f2087c98
-rwxr-xr-xchrome/browser/sync/syncable/directory_backing_store.cc11
1 files changed, 10 insertions, 1 deletions
diff --git a/chrome/browser/sync/syncable/directory_backing_store.cc b/chrome/browser/sync/syncable/directory_backing_store.cc
index 4cdf7c2..216e785 100755
--- a/chrome/browser/sync/syncable/directory_backing_store.cc
+++ b/chrome/browser/sync/syncable/directory_backing_store.cc
@@ -241,6 +241,15 @@ bool DirectoryBackingStore::SaveChanges(
const Directory::SaveChangesSnapshot& snapshot) {
sqlite3* dbhandle = LazyGetSaveHandle();
+ // SQLTransaction::BeginExclusive causes a disk write to occur. This is not
+ // something that should happen every 10 seconds when this function runs, so
+ // just stop here if there's nothing to save.
+ bool save_info =
+ (Directory::KERNEL_SHARE_INFO_DIRTY == snapshot.kernel_info_status);
+ if (snapshot.dirty_metas.size() < 1 && snapshot.dirty_xattrs.size() < 1 &&
+ !save_info)
+ return true;
+
SQLTransaction transaction(dbhandle);
if (SQLITE_OK != transaction.BeginExclusive())
return false;
@@ -264,7 +273,7 @@ bool DirectoryBackingStore::SaveChanges(
}
}
- if (Directory::KERNEL_SHARE_INFO_DIRTY == snapshot.kernel_info_status) {
+ if (save_info) {
const Directory::PersistedKernelInfo& info = snapshot.kernel_info;
SQLStatement update;
update.prepare(dbhandle, "UPDATE share_info "