diff options
author | Christopher Tate <ctate@google.com> | 2010-02-05 10:41:27 -0800 |
---|---|---|
committer | Christopher Tate <ctate@google.com> | 2010-02-05 10:41:27 -0800 |
commit | c61da3136b1ffce9152f54ff19cab2782cb8450b (patch) | |
tree | c7eb49ebb63b3e028600668c486b42f32c88ba77 /services/java/com/android/server/BackupManagerService.java | |
parent | 8fca8ab6849d83861b86c6a3af189adf86c51d07 (diff) | |
download | frameworks_base-c61da3136b1ffce9152f54ff19cab2782cb8450b.zip frameworks_base-c61da3136b1ffce9152f54ff19cab2782cb8450b.tar.gz frameworks_base-c61da3136b1ffce9152f54ff19cab2782cb8450b.tar.bz2 |
Don't hold the backup queue lock across a backup operation
This got lost in the shuffle when the backup process was retooled to run
synchronously within a single spun-off HandlerThread. Formerly it was okay
to hold the lock around the point in time when the backup service thread was
being spun off, but once that became synchronous it wound up locking out
apps' calls to dataChanged(), which in turn led to ANRs.
Bug: 2421333
Change-Id: Icf378e5733af5f28a689c564494486cd3555eca7
Diffstat (limited to 'services/java/com/android/server/BackupManagerService.java')
-rw-r--r-- | services/java/com/android/server/BackupManagerService.java | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/services/java/com/android/server/BackupManagerService.java b/services/java/com/android/server/BackupManagerService.java index 6795bdd..2f845e1 100644 --- a/services/java/com/android/server/BackupManagerService.java +++ b/services/java/com/android/server/BackupManagerService.java @@ -258,8 +258,11 @@ class BackupManagerService extends IBackupManager.Stub { // snapshot the pending-backup set and work on that ArrayList<BackupRequest> queue = new ArrayList<BackupRequest>(); + File oldJournal = mJournal; synchronized (mQueueLock) { - // Do we have any work to do? + // Do we have any work to do? Construct the work queue + // then release the synchronization lock to actually run + // the backup. if (mPendingBackups.size() > 0) { for (BackupRequest b: mPendingBackups.values()) { queue.add(b); @@ -268,20 +271,22 @@ class BackupManagerService extends IBackupManager.Stub { mPendingBackups.clear(); // Start a new backup-queue journal file too - File oldJournal = mJournal; mJournal = null; - // At this point, we have started a new journal file, and the old - // file identity is being passed to the backup processing thread. - // When it completes successfully, that old journal file will be - // deleted. If we crash prior to that, the old journal is parsed - // at next boot and the journaled requests fulfilled. - (new PerformBackupTask(transport, queue, oldJournal)).run(); - } else { - Log.v(TAG, "Backup requested but nothing pending"); - mWakelock.release(); } } + + if (queue.size() > 0) { + // At this point, we have started a new journal file, and the old + // file identity is being passed to the backup processing thread. + // When it completes successfully, that old journal file will be + // deleted. If we crash prior to that, the old journal is parsed + // at next boot and the journaled requests fulfilled. + (new PerformBackupTask(transport, queue, oldJournal)).run(); + } else { + Log.v(TAG, "Backup requested but nothing pending"); + mWakelock.release(); + } break; } |