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

Commit 26025a06 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Always close file descriptors"

parents f94eb295 725e8f68
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);