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

Commit 8fe381f0 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Always close file descriptors" into pi-dev

parents a2b1e5f0 3c0dc27a
Loading
Loading
Loading
Loading
+3 −4
Original line number Diff line number Diff line
@@ -59,10 +59,9 @@ public class NetlinkSocket {
        final String errPrefix = "Error in NetlinkSocket.sendOneShotKernelMessage";
        final long IO_TIMEOUT = 300L;

        FileDescriptor fd;
        final FileDescriptor fd = forProto(nlProto);

        try {
            fd = forProto(nlProto);
            connectToKernel(fd);
            sendMessage(fd, msg, 0, msg.length, IO_TIMEOUT);
            final ByteBuffer bytes = recvMessage(fd, DEFAULT_RECV_BUFSIZE, IO_TIMEOUT);
@@ -96,10 +95,10 @@ public class NetlinkSocket {
        } catch (SocketException e) {
            Log.e(TAG, errPrefix, e);
            throw new ErrnoException(errPrefix, EIO, e);
        }

        } finally {
            IoUtils.closeQuietly(fd);
        }
    }

    public static FileDescriptor forProto(int nlProto) throws ErrnoException {
        final FileDescriptor fd = Os.socket(AF_NETLINK, SOCK_DGRAM, nlProto);