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

Commit 929b4855 authored by Nick Kralevich's avatar Nick Kralevich
Browse files

Fix a problem with leaking UDP sockets.

When dealing with any kind of limited operating system resource,
we should ensure that we properly close everything that we
open, rather than relying on the system garbage collector.

Change-Id: Ic71f710eb85ac71a91b7a1215647c75010d37643
parent c44c4742
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -1217,8 +1217,9 @@ public class WifiWatchdogService {
        private static Random sRandom = new Random();
        
        static boolean isDnsReachable(int dns, int timeout) {
            DatagramSocket socket = null;
            try {
                DatagramSocket socket = new DatagramSocket();
                socket = new DatagramSocket();
                
                // Set some socket properties
                socket.setSoTimeout(timeout);
@@ -1271,6 +1272,10 @@ public class WifiWatchdogService {
                    Slog.d(TAG, "DnsPinger.isReachable got an unknown exception", e);
                }
                return false;
            } finally {
                if (socket != null) {
                    socket.close();
                }
            }
        }