Merge "Always close file descriptors" into pi-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
8fe381f0fd
@@ -59,10 +59,9 @@ public class NetlinkSocket {
|
|||||||
final String errPrefix = "Error in NetlinkSocket.sendOneShotKernelMessage";
|
final String errPrefix = "Error in NetlinkSocket.sendOneShotKernelMessage";
|
||||||
final long IO_TIMEOUT = 300L;
|
final long IO_TIMEOUT = 300L;
|
||||||
|
|
||||||
FileDescriptor fd;
|
final FileDescriptor fd = forProto(nlProto);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
fd = forProto(nlProto);
|
|
||||||
connectToKernel(fd);
|
connectToKernel(fd);
|
||||||
sendMessage(fd, msg, 0, msg.length, IO_TIMEOUT);
|
sendMessage(fd, msg, 0, msg.length, IO_TIMEOUT);
|
||||||
final ByteBuffer bytes = recvMessage(fd, DEFAULT_RECV_BUFSIZE, IO_TIMEOUT);
|
final ByteBuffer bytes = recvMessage(fd, DEFAULT_RECV_BUFSIZE, IO_TIMEOUT);
|
||||||
@@ -96,9 +95,9 @@ public class NetlinkSocket {
|
|||||||
} catch (SocketException e) {
|
} catch (SocketException e) {
|
||||||
Log.e(TAG, errPrefix, e);
|
Log.e(TAG, errPrefix, e);
|
||||||
throw new ErrnoException(errPrefix, EIO, e);
|
throw new ErrnoException(errPrefix, EIO, e);
|
||||||
|
} finally {
|
||||||
|
IoUtils.closeQuietly(fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
IoUtils.closeQuietly(fd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FileDescriptor forProto(int nlProto) throws ErrnoException {
|
public static FileDescriptor forProto(int nlProto) throws ErrnoException {
|
||||||
|
|||||||
Reference in New Issue
Block a user