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

Commit ca848c47 authored by Chris Wailes's avatar Chris Wailes
Browse files

Removes a vestigial code path.

This patch removes the getAncillaryFileDescriptors() call from the
ZygoteConnection class because the function setFileDescriptorsForSend(),
which sets the values retrieved by getAncillaryFileDescriptors(), is
never called on the socket.

Test: m & flash & boot & launch applications
Change-Id: I994379b2c2da7d0d1fb47907f00229bfc92328c3
parent 8645b7d3
Loading
Loading
Loading
Loading
+4 −34
Original line number Original line Diff line number Diff line
@@ -19,9 +19,6 @@ package com.android.internal.os;
import static android.system.OsConstants.F_SETFD;
import static android.system.OsConstants.F_SETFD;
import static android.system.OsConstants.O_CLOEXEC;
import static android.system.OsConstants.O_CLOEXEC;
import static android.system.OsConstants.POLLIN;
import static android.system.OsConstants.POLLIN;
import static android.system.OsConstants.STDERR_FILENO;
import static android.system.OsConstants.STDIN_FILENO;
import static android.system.OsConstants.STDOUT_FILENO;


import static com.android.internal.os.ZygoteConnectionConstants.CONNECTION_TIMEOUT_MILLIS;
import static com.android.internal.os.ZygoteConnectionConstants.CONNECTION_TIMEOUT_MILLIS;
import static com.android.internal.os.ZygoteConnectionConstants.WRAPPED_PID_TIMEOUT_MILLIS;
import static com.android.internal.os.ZygoteConnectionConstants.WRAPPED_PID_TIMEOUT_MILLIS;
@@ -129,13 +126,9 @@ class ZygoteConnection {
    Runnable processOneCommand(ZygoteServer zygoteServer) {
    Runnable processOneCommand(ZygoteServer zygoteServer) {
        String args[];
        String args[];
        ZygoteArguments parsedArgs = null;
        ZygoteArguments parsedArgs = null;
        FileDescriptor[] descriptors;


        try {
        try {
            args = Zygote.readArgumentList(mSocketReader);
            args = Zygote.readArgumentList(mSocketReader);

            // TODO (chriswailes): Remove this and add an assert.
            descriptors = mSocket.getAncillaryFileDescriptors();
        } catch (IOException ex) {
        } catch (IOException ex) {
            throw new IllegalStateException("IOException on command socket", ex);
            throw new IllegalStateException("IOException on command socket", ex);
        }
        }
@@ -279,14 +272,13 @@ class ZygoteConnection {
                IoUtils.closeQuietly(serverPipeFd);
                IoUtils.closeQuietly(serverPipeFd);
                serverPipeFd = null;
                serverPipeFd = null;


                return handleChildProc(parsedArgs, descriptors, childPipeFd,
                return handleChildProc(parsedArgs, childPipeFd, parsedArgs.mStartChildZygote);
                        parsedArgs.mStartChildZygote);
            } else {
            } else {
                // In the parent. A pid < 0 indicates a failure and will be handled in
                // In the parent. A pid < 0 indicates a failure and will be handled in
                // handleParentProc.
                // handleParentProc.
                IoUtils.closeQuietly(childPipeFd);
                IoUtils.closeQuietly(childPipeFd);
                childPipeFd = null;
                childPipeFd = null;
                handleParentProc(pid, descriptors, serverPipeFd);
                handleParentProc(pid, serverPipeFd);
                return null;
                return null;
            }
            }
        } finally {
        } finally {
@@ -546,11 +538,10 @@ class ZygoteConnection {
     * if successful or returning if failed.
     * if successful or returning if failed.
     *
     *
     * @param parsedArgs non-null; zygote args
     * @param parsedArgs non-null; zygote args
     * @param descriptors null-ok; new file descriptors for stdio if available.
     * @param pipeFd null-ok; pipe for communication back to Zygote.
     * @param pipeFd null-ok; pipe for communication back to Zygote.
     * @param isZygote whether this new child process is itself a new Zygote.
     * @param isZygote whether this new child process is itself a new Zygote.
     */
     */
    private Runnable handleChildProc(ZygoteArguments parsedArgs, FileDescriptor[] descriptors,
    private Runnable handleChildProc(ZygoteArguments parsedArgs,
            FileDescriptor pipeFd, boolean isZygote) {
            FileDescriptor pipeFd, boolean isZygote) {
        /**
        /**
         * By the time we get here, the native code has closed the two actual Zygote
         * By the time we get here, the native code has closed the two actual Zygote
@@ -559,19 +550,6 @@ class ZygoteConnection {
         */
         */


        closeSocket();
        closeSocket();
        if (descriptors != null) {
            try {
                Os.dup2(descriptors[0], STDIN_FILENO);
                Os.dup2(descriptors[1], STDOUT_FILENO);
                Os.dup2(descriptors[2], STDERR_FILENO);

                for (FileDescriptor fd: descriptors) {
                    IoUtils.closeQuietly(fd);
                }
            } catch (ErrnoException ex) {
                Log.e(TAG, "Error reopening stdio", ex);
            }
        }


        Zygote.setAppProcessName(parsedArgs, TAG);
        Zygote.setAppProcessName(parsedArgs, TAG);


@@ -601,21 +579,13 @@ class ZygoteConnection {
     *
     *
     * @param pid != 0; pid of child if &gt; 0 or indication of failed fork
     * @param pid != 0; pid of child if &gt; 0 or indication of failed fork
     * if &lt; 0;
     * if &lt; 0;
     * @param descriptors null-ok; file descriptors for child's new stdio if
     * specified.
     * @param pipeFd null-ok; pipe for communication with child.
     * @param pipeFd null-ok; pipe for communication with child.
     */
     */
    private void handleParentProc(int pid, FileDescriptor[] descriptors, FileDescriptor pipeFd) {
    private void handleParentProc(int pid, FileDescriptor pipeFd) {
        if (pid > 0) {
        if (pid > 0) {
            setChildPgid(pid);
            setChildPgid(pid);
        }
        }


        if (descriptors != null) {
            for (FileDescriptor fd: descriptors) {
                IoUtils.closeQuietly(fd);
            }
        }

        boolean usingWrapper = false;
        boolean usingWrapper = false;
        if (pipeFd != null && pid > 0) {
        if (pipeFd != null && pid > 0) {
            int innerPid = -1;
            int innerPid = -1;