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

Commit b8a5aa1f authored by Erik Kline's avatar Erik Kline Committed by android-build-merger
Browse files

Merge "Always close file descriptors" am: 26025a06 am: de8eac9a

am: ed6cc299

Change-Id: I212cbbe134bba4580a6e73de9bb77e712d25c9a6
parents 6e162540 ed6cc299
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);