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

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

Explicitly close pipe end when we cease operations...

am: 3bed1c0e

* commit '3bed1c0e':
  Explicitly close pipe end when we cease operations...

Change-Id: Id7cadc496b8fbe209a39cf058282b79d476d3827
parents 57b9e7da 3bed1c0e
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -3528,6 +3528,7 @@ public class BackupManagerService {

    private void routeSocketDataToOutput(ParcelFileDescriptor inPipe, OutputStream out)
            throws IOException {
        // We do not take close() responsibility for the pipe FD
        FileInputStream raw = new FileInputStream(inPipe.getFileDescriptor());
        DataInputStream in = new DataInputStream(raw);

@@ -4445,7 +4446,8 @@ public class BackupManagerService {
                        (new Thread(backupRunner, "package-backup-bridge")).start();

                        // Read data off the engine pipe and pass it to the transport
                        // pipe until we hit EOD on the input stream.
                        // pipe until we hit EOD on the input stream.  We do not take
                        // close() responsibility for these FDs into these stream wrappers.
                        FileInputStream in = new FileInputStream(
                                enginePipes[0].getFileDescriptor());
                        FileOutputStream out = new FileOutputStream(
@@ -8579,7 +8581,10 @@ if (MORE_DEBUG) Slog.v(TAG, " + got " + nRead + "; now wanting " + (size - soF
            EngineThread(FullRestoreEngine engine, ParcelFileDescriptor engineSocket) {
                mEngine = engine;
                engine.setRunning(true);
                mEngineStream = new FileInputStream(engineSocket.getFileDescriptor());
                // We *do* want this FileInputStream to own the underlying fd, so that
                // when we are finished with it, it closes this end of the pipe in a way
                // that signals its other end.
                mEngineStream = new FileInputStream(engineSocket.getFileDescriptor(), true);
            }

            public boolean isRunning() {
@@ -8598,6 +8603,8 @@ if (MORE_DEBUG) Slog.v(TAG, " + got " + nRead + "; now wanting " + (size - soF
                        mEngine.restoreOneFile(mEngineStream, false);
                    }
                } finally {
                    // Because mEngineStream adopted its underlying FD, this also
                    // closes this end of the pipe.
                    IoUtils.closeQuietly(mEngineStream);
                }
            }