diff options
| author | 2016-07-15 01:38:02 +0000 | |
|---|---|---|
| committer | 2016-07-15 01:38:03 +0000 | |
| commit | 4595bc7f12cadfc0ec7b1f9fe0945fd2e45fb425 (patch) | |
| tree | d23bfc0593802c10d25ec0c0d407d338dcac9535 | |
| parent | b30e1f75d1e9c127c038bb4dec335b9a43f6fa9f (diff) | |
| parent | ad869cc908ff22956f8df47cb127e3446793b787 (diff) | |
Merge "Thread-safe pipe teardown during restore operations" into nyc-mr1-dev
| -rw-r--r-- | services/backup/java/com/android/server/backup/BackupManagerService.java | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/services/backup/java/com/android/server/backup/BackupManagerService.java b/services/backup/java/com/android/server/backup/BackupManagerService.java index 5ce8c9e6e4cb..d10080b06823 100644 --- a/services/backup/java/com/android/server/backup/BackupManagerService.java +++ b/services/backup/java/com/android/server/backup/BackupManagerService.java @@ -5707,16 +5707,21 @@ public class BackupManagerService { } void tearDownPipes() { - if (mPipes != null) { - try { - mPipes[0].close(); - mPipes[0] = null; - mPipes[1].close(); - mPipes[1] = null; - } catch (IOException e) { - Slog.w(TAG, "Couldn't close agent pipes", e); + // Teardown might arise from the inline restore processing or from the asynchronous + // timeout mechanism, and these might race. Make sure we don't try to close and + // null out the pipes twice. + synchronized (this) { + if (mPipes != null) { + try { + mPipes[0].close(); + mPipes[0] = null; + mPipes[1].close(); + mPipes[1] = null; + } catch (IOException e) { + Slog.w(TAG, "Couldn't close agent pipes", e); + } + mPipes = null; } - mPipes = null; } } |