Skip to content
Snippets Groups Projects
Commit 3f48f42c authored by Jean Chalard's avatar Jean Chalard Committed by Gerrit Code Review
Browse files

Merge "Fix a socket leak" into main

parents f411c022 90050b25
No related branches found
No related tags found
No related merge requests found
......@@ -340,8 +340,9 @@ public class NetworkDiagnostics {
@TargetApi(Build.VERSION_CODES.S)
private int getMtuForTarget(InetAddress target) {
final int family = target instanceof Inet4Address ? AF_INET : AF_INET6;
FileDescriptor socket = null;
try {
final FileDescriptor socket = Os.socket(family, SOCK_DGRAM, 0);
socket = Os.socket(family, SOCK_DGRAM, 0);
mNetwork.bindSocket(socket);
Os.connect(socket, target, 0);
if (family == AF_INET) {
......@@ -352,6 +353,8 @@ public class NetworkDiagnostics {
} catch (ErrnoException | IOException e) {
Log.e(TAG, "Can't get MTU for destination " + target, e);
return -1;
} finally {
IoUtils.closeQuietly(socket);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment