Commit 90ed7179 authored by nyquist@chromium.org's avatar nyquist@chromium.org

[sync] Fix deadlock in SessionModelAssociator for Android.

If there exists session sync nodes that use the cache GUID as the ID,
Chrome for Android goes into a deadlock while associating the tabs.

Since SessionModelAssociator::DeleteForeignSession uses its own
syncer::WriteTransaction, we must ensure that we only call that method
without currently holding a syncer::WriteTransaction.

BUG=175782

Review URL: https://chromiumcodereview.appspot.com/12253010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@182416 0039d316-1c4b-4281-b951-d872f2087c98
parent 547dbf57
...@@ -613,6 +613,9 @@ syncer::SyncError SessionModelAssociator::AssociateModels( ...@@ -613,6 +613,9 @@ syncer::SyncError SessionModelAssociator::AssociateModels(
scoped_ptr<DeviceInfo> local_device_info(sync_service_->GetLocalDeviceInfo()); scoped_ptr<DeviceInfo> local_device_info(sync_service_->GetLocalDeviceInfo());
#if defined(OS_ANDROID)
std::string transaction_tag;
#endif
// Read any available foreign sessions and load any session data we may have. // Read any available foreign sessions and load any session data we may have.
// If we don't have any local session data in the db, create a header node. // If we don't have any local session data in the db, create a header node.
{ {
...@@ -672,11 +675,16 @@ syncer::SyncError SessionModelAssociator::AssociateModels( ...@@ -672,11 +675,16 @@ syncer::SyncError SessionModelAssociator::AssociateModels(
local_session_syncid_ = write_node.GetId(); local_session_syncid_ = write_node.GetId();
} }
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
std::string transaction_tag = GetMachineTagFromTransaction(&trans); transaction_tag = GetMachineTagFromTransaction(&trans);
if (current_machine_tag_.compare(transaction_tag) != 0)
DeleteForeignSession(transaction_tag);
#endif #endif
} }
#if defined(OS_ANDROID)
// We need to delete foreign sessions after giving up our
// syncer::WriteTransaction, since DeleteForeignSession(std::string&) uses
// its own syncer::WriteTransaction.
if (current_machine_tag_.compare(transaction_tag) != 0)
DeleteForeignSession(transaction_tag);
#endif
// Check if anything has changed on the client side. // Check if anything has changed on the client side.
if (!UpdateSyncModelDataFromClient(&error)) { if (!UpdateSyncModelDataFromClient(&error)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment