Merge "Fix a problem with leaking UDP sockets." into kraken
This commit is contained in:
committed by
Android (Google) Code Review
commit
2feafeffb8
@@ -1217,8 +1217,9 @@ public class WifiWatchdogService {
|
|||||||
private static Random sRandom = new Random();
|
private static Random sRandom = new Random();
|
||||||
|
|
||||||
static boolean isDnsReachable(int dns, int timeout) {
|
static boolean isDnsReachable(int dns, int timeout) {
|
||||||
|
DatagramSocket socket = null;
|
||||||
try {
|
try {
|
||||||
DatagramSocket socket = new DatagramSocket();
|
socket = new DatagramSocket();
|
||||||
|
|
||||||
// Set some socket properties
|
// Set some socket properties
|
||||||
socket.setSoTimeout(timeout);
|
socket.setSoTimeout(timeout);
|
||||||
@@ -1271,6 +1272,10 @@ public class WifiWatchdogService {
|
|||||||
Slog.d(TAG, "DnsPinger.isReachable got an unknown exception", e);
|
Slog.d(TAG, "DnsPinger.isReachable got an unknown exception", e);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
} finally {
|
||||||
|
if (socket != null) {
|
||||||
|
socket.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user