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

Commit b2a1985b authored by Jeff Brown's avatar Jeff Brown
Browse files

Avoid rebuilding epoll set when PFD status report is done.

If we close the PFD status channel before returning, then the Looper
will take care of unregistering it correctly but it will end up
doing extra work to rebuild the epoll set to work around a limitation
of the epoll interface.  If we unregister the FD first then this
extra work will not be required so it's slightly more efficient
this way.

Bug: 19715279
Change-Id: I0f7b90f3458adf1894b7561c05fa842fdb87b498
parent 6fd9f9af
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -235,8 +235,8 @@ public class ParcelFileDescriptor implements Parcelable, Closeable {

        final FileDescriptor[] comm = createCommSocketPair();
        final ParcelFileDescriptor pfd = new ParcelFileDescriptor(fd, comm[0]);

        handler.getLooper().getQueue().registerFileDescriptorCallback(comm[1],
        final MessageQueue queue = handler.getLooper().getQueue();
        queue.registerFileDescriptorCallback(comm[1],
                FileDescriptorCallback.EVENT_INPUT, new FileDescriptorCallback() {
            @Override
            public int onFileDescriptorEvents(FileDescriptor fd, int events) {
@@ -248,9 +248,10 @@ public class ParcelFileDescriptor implements Parcelable, Closeable {
                    status = new Status(Status.DEAD);
                }
                if (status != null) {
                    queue.unregisterFileDescriptorCallback(fd);
                    IoUtils.closeQuietly(fd);
                    listener.onClose(status.asIOException());
                    return 0; // unregister the callback
                    return 0;
                }
                return EVENT_INPUT;
            }