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

Unified Diff: chrome/browser/sync/syncable/syncable.cc

Issue 2805095: Fix deadlock by introducing a new transaction event. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 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: chrome/browser/sync/syncable/syncable.cc
diff --git a/chrome/browser/sync/syncable/syncable.cc b/chrome/browser/sync/syncable/syncable.cc
index 7c6cc712802545e9a09686a0d16fc7bb8472ed6f..5516c594a52d9afedee00b69785acf0e761e77bf 100644
--- a/chrome/browser/sync/syncable/syncable.cc
+++ b/chrome/browser/sync/syncable/syncable.cc
@@ -950,6 +950,8 @@ BaseTransaction::BaseTransaction(Directory* directory, const char* name,
Lock();
}
+BaseTransaction::~BaseTransaction() {}
+
void BaseTransaction::UnlockAndLog(OriginalEntries* originals_arg) {
dirkernel_->transaction_mutex.AssertAcquired();
@@ -972,8 +974,17 @@ void BaseTransaction::UnlockAndLog(OriginalEntries* originals_arg) {
originals.get(), this, writer_ };
dirkernel_->changes_channel.Notify(event);
+ // Necessary for reads to be performed prior to transaction mutex release.
+ // Allows the listener to use the current transaction to perform reads.
+ DirectoryChangeEvent ending_event =
+ { DirectoryChangeEvent::TRANSACTION_ENDING,
+ NULL, this, INVALID };
+ dirkernel_->changes_channel.Notify(ending_event);
+
dirkernel_->transaction_mutex.Release();
+ // Directly after transaction mutex release, but lock on changes channel.
+ // You cannot be re-entrant to a transaction in this handler.
DirectoryChangeEvent complete_event =
{ DirectoryChangeEvent::TRANSACTION_COMPLETE,
NULL, NULL, INVALID };
« chrome/browser/sync/engine/syncapi.cc ('K') | « chrome/browser/sync/syncable/syncable.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698