OSDN Git Service

Offload the mRunningFullBackupTask.handleCancel() call from the main
authorMichal Karpinski <mkarpinski@google.com>
Thu, 20 Apr 2017 16:00:31 +0000 (17:00 +0100)
committerMichal Karpinski <mkarpinski@google.com>
Tue, 25 Apr 2017 18:33:18 +0000 (19:33 +0100)
thread to another thread

The system_server process was being killed by Watchdog, as the main
thread was waiting for the mCancelLock for over a minute.

Bug: 35968123
Test: make gts -j40 && gts-tradefed run gts -m GtsGmscoreHostTestCases -t com.google.android.gts.backup.BackupManagerHostTest
Change-Id: Ia146569d2c741b35a6f6c9bfc4c5ddf8539b6242

services/backup/java/com/android/server/backup/BackupManagerService.java

index 9301006..1b970e5 100644 (file)
@@ -5641,14 +5641,24 @@ public class BackupManagerService {
     // The job scheduler says our constraints don't hold any more,
     // so tear down any ongoing backup task right away.
     void endFullBackup() {
-        synchronized (mQueueLock) {
-            if (mRunningFullBackupTask != null) {
-                if (DEBUG_SCHEDULING) {
-                    Slog.i(TAG, "Telling running backup to stop");
+        // offload the mRunningFullBackupTask.handleCancel() call to another thread,
+        // as we might have to wait for mCancelLock
+        Runnable endFullBackupRunnable = new Runnable() {
+            @Override
+            public void run() {
+                PerformFullTransportBackupTask pftbt = null;
+                synchronized (mQueueLock) {
+                    if (mRunningFullBackupTask != null) {
+                        if (DEBUG_SCHEDULING) {
+                            Slog.i(TAG, "Telling running backup to stop");
+                        }
+                        pftbt = mRunningFullBackupTask;
+                    }
                 }
-                mRunningFullBackupTask.handleCancel(true);
+                pftbt.handleCancel(true);
             }
-        }
+        };
+        new Thread(endFullBackupRunnable, "end-full-backup").start();
     }
 
     // ----- Restore infrastructure -----