Skip to content

Commit a2c6d5b

Browse files
committed
do not merge: cherry-picked 929b485 from master branch
Change-Id: Ie20371234a531f65f523682a0d0c27394dc30afa
1 parent b00854d commit a2c6d5b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

services/java/com/android/server/WifiWatchdogService.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1217,8 +1217,9 @@ private static class DnsPinger {
12171217
private static Random sRandom = new Random();
12181218

12191219
static boolean isDnsReachable(int dns, int timeout) {
1220+
DatagramSocket socket = null;
12201221
try {
1221-
DatagramSocket socket = new DatagramSocket();
1222+
socket = new DatagramSocket();
12221223

12231224
// Set some socket properties
12241225
socket.setSoTimeout(timeout);
@@ -1271,6 +1272,10 @@ static boolean isDnsReachable(int dns, int timeout) {
12711272
Slog.d(TAG, "DnsPinger.isReachable got an unknown exception", e);
12721273
}
12731274
return false;
1275+
} finally {
1276+
if (socket != null) {
1277+
socket.close();
1278+
}
12741279
}
12751280
}
12761281

0 commit comments

Comments
 (0)