Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4f7942cc authored by Christopher Tate's avatar Christopher Tate Committed by android-build-merger
Browse files

Merge "Fix deadlock when full data backup times out" into nyc-dev

am: 8384d815

* commit '8384d815':
  Fix deadlock when full data backup times out
parents 8b4aeb2f 8384d815
Loading
Loading
Loading
Loading
+22 −8
Original line number Original line Diff line number Diff line
@@ -2918,9 +2918,15 @@ public class BackupManagerService {
                mBackupRunning = false;
                mBackupRunning = false;
                if (mStatus == BackupTransport.TRANSPORT_NOT_INITIALIZED) {
                if (mStatus == BackupTransport.TRANSPORT_NOT_INITIALIZED) {
                    // Make sure we back up everything and perform the one-time init
                    // Make sure we back up everything and perform the one-time init
                    clearMetadata();
                    if (MORE_DEBUG) Slog.d(TAG, "Server requires init; rerunning");
                    if (MORE_DEBUG) Slog.d(TAG, "Server requires init; rerunning");
                    addBackupTrace("init required; rerunning");
                    addBackupTrace("init required; rerunning");
                    try {
                        mPendingInits.add(mTransport.transportDirName());
                    } catch (Exception e) {
                        Slog.w(TAG, "Failed to query transport name heading for init", e);
                        // swallow it and proceed; we don't rely on this
                    }
                    clearMetadata();
                    backupNow();
                    backupNow();
                }
                }
            }
            }
@@ -4451,14 +4457,22 @@ public class BackupManagerService {
                            }
                            }
                        }
                        }


                        // TRANSPORT_ERROR here means that we've hit an error that the runner
                        // doesn't know about, so it's still moving data but we're pulling the
                        // rug out from under it.  Don't ask for its result:  we already know better
                        // and we'll hang if we block waiting for it, since it relies on us to
                        // read back the data it's writing into the engine.  Just proceed with
                        // a graceful failure.  The runner/engine mechanism will tear itself
                        // down cleanly when we close the pipes from this end.
                        if (backupPackageStatus != BackupTransport.TRANSPORT_ERROR) {
                            // We still could fail in backup runner thread, getting result from there.
                            // We still could fail in backup runner thread, getting result from there.
                            int backupRunnerResult = backupRunner.getBackupResultBlocking();
                            int backupRunnerResult = backupRunner.getBackupResultBlocking();
                        if (backupPackageStatus != BackupTransport.TRANSPORT_ERROR
                            if (backupRunnerResult != BackupTransport.TRANSPORT_OK) {
                                && backupRunnerResult != BackupTransport.TRANSPORT_OK) {
                                // If there was an error in runner thread and
                                // If there was an error in runner thread and
                                // not TRANSPORT_ERROR here, overwrite it.
                                // not TRANSPORT_ERROR here, overwrite it.
                                backupPackageStatus = backupRunnerResult;
                                backupPackageStatus = backupRunnerResult;
                            }
                            }
                        }


                        if (MORE_DEBUG) {
                        if (MORE_DEBUG) {
                            Slog.i(TAG, "Done trying to send backup data: result="
                            Slog.i(TAG, "Done trying to send backup data: result="