Loading services/net/java/android/net/ip/IpReachabilityMonitor.java +13 −20 Original line number Diff line number Diff line Loading @@ -50,9 +50,9 @@ import java.net.NetworkInterface; import java.net.SocketAddress; import java.net.SocketException; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; Loading Loading @@ -163,8 +163,7 @@ public class IpReachabilityMonitor { private Map<InetAddress, Short> mIpWatchList = new HashMap<>(); @GuardedBy("mLock") private int mIpWatchListVersion; @GuardedBy("mLock") private boolean mRunning; private volatile boolean mRunning; // Time in milliseconds of the last forced probe request. private volatile long mLastProbeTimeMs; Loading Loading @@ -246,7 +245,7 @@ public class IpReachabilityMonitor { } public void stop() { synchronized (mLock) { mRunning = false; } mRunning = false; clearLinkProperties(); mNetlinkSocketObserver.clearNetlinkSocket(); } Loading Loading @@ -281,12 +280,6 @@ public class IpReachabilityMonitor { } } private boolean stillRunning() { synchronized (mLock) { return mRunning; } } private static boolean isOnLink(List<RouteInfo> routes, InetAddress ip) { for (RouteInfo route : routes) { if (!route.hasGateway() && route.matches(ip)) { Loading Loading @@ -390,12 +383,12 @@ public class IpReachabilityMonitor { } public void probeAll() { Set<InetAddress> ipProbeList = new HashSet<InetAddress>(); final List<InetAddress> ipProbeList; synchronized (mLock) { ipProbeList.addAll(mIpWatchList.keySet()); ipProbeList = new ArrayList<>(mIpWatchList.keySet()); } if (!ipProbeList.isEmpty() && stillRunning()) { if (!ipProbeList.isEmpty() && mRunning) { // Keep the CPU awake long enough to allow all ARP/ND // probes a reasonable chance at success. See b/23197666. // Loading @@ -406,7 +399,7 @@ public class IpReachabilityMonitor { } for (InetAddress target : ipProbeList) { if (!stillRunning()) { if (!mRunning) { break; } final int returnValue = probeNeighbor(mInterfaceIndex, target); Loading Loading @@ -451,21 +444,21 @@ public class IpReachabilityMonitor { @Override public void run() { if (VDBG) { Log.d(TAG, "Starting observing thread."); } synchronized (mLock) { mRunning = true; } mRunning = true; try { setupNetlinkSocket(); } catch (ErrnoException | SocketException e) { Log.e(TAG, "Failed to suitably initialize a netlink socket", e); synchronized (mLock) { mRunning = false; } mRunning = false; } ByteBuffer byteBuffer; while (stillRunning()) { while (mRunning) { final ByteBuffer byteBuffer; try { byteBuffer = recvKernelReply(); } catch (ErrnoException e) { if (stillRunning()) { Log.w(TAG, "ErrnoException: ", e); } if (mRunning) { Log.w(TAG, "ErrnoException: ", e); } break; } final long whenMs = SystemClock.elapsedRealtime(); Loading @@ -477,7 +470,7 @@ public class IpReachabilityMonitor { clearNetlinkSocket(); synchronized (mLock) { mRunning = false; } mRunning = false; // Not a no-op when ErrnoException happened. if (VDBG) { Log.d(TAG, "Finishing observing thread."); } } Loading Loading
services/net/java/android/net/ip/IpReachabilityMonitor.java +13 −20 Original line number Diff line number Diff line Loading @@ -50,9 +50,9 @@ import java.net.NetworkInterface; import java.net.SocketAddress; import java.net.SocketException; import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; Loading Loading @@ -163,8 +163,7 @@ public class IpReachabilityMonitor { private Map<InetAddress, Short> mIpWatchList = new HashMap<>(); @GuardedBy("mLock") private int mIpWatchListVersion; @GuardedBy("mLock") private boolean mRunning; private volatile boolean mRunning; // Time in milliseconds of the last forced probe request. private volatile long mLastProbeTimeMs; Loading Loading @@ -246,7 +245,7 @@ public class IpReachabilityMonitor { } public void stop() { synchronized (mLock) { mRunning = false; } mRunning = false; clearLinkProperties(); mNetlinkSocketObserver.clearNetlinkSocket(); } Loading Loading @@ -281,12 +280,6 @@ public class IpReachabilityMonitor { } } private boolean stillRunning() { synchronized (mLock) { return mRunning; } } private static boolean isOnLink(List<RouteInfo> routes, InetAddress ip) { for (RouteInfo route : routes) { if (!route.hasGateway() && route.matches(ip)) { Loading Loading @@ -390,12 +383,12 @@ public class IpReachabilityMonitor { } public void probeAll() { Set<InetAddress> ipProbeList = new HashSet<InetAddress>(); final List<InetAddress> ipProbeList; synchronized (mLock) { ipProbeList.addAll(mIpWatchList.keySet()); ipProbeList = new ArrayList<>(mIpWatchList.keySet()); } if (!ipProbeList.isEmpty() && stillRunning()) { if (!ipProbeList.isEmpty() && mRunning) { // Keep the CPU awake long enough to allow all ARP/ND // probes a reasonable chance at success. See b/23197666. // Loading @@ -406,7 +399,7 @@ public class IpReachabilityMonitor { } for (InetAddress target : ipProbeList) { if (!stillRunning()) { if (!mRunning) { break; } final int returnValue = probeNeighbor(mInterfaceIndex, target); Loading Loading @@ -451,21 +444,21 @@ public class IpReachabilityMonitor { @Override public void run() { if (VDBG) { Log.d(TAG, "Starting observing thread."); } synchronized (mLock) { mRunning = true; } mRunning = true; try { setupNetlinkSocket(); } catch (ErrnoException | SocketException e) { Log.e(TAG, "Failed to suitably initialize a netlink socket", e); synchronized (mLock) { mRunning = false; } mRunning = false; } ByteBuffer byteBuffer; while (stillRunning()) { while (mRunning) { final ByteBuffer byteBuffer; try { byteBuffer = recvKernelReply(); } catch (ErrnoException e) { if (stillRunning()) { Log.w(TAG, "ErrnoException: ", e); } if (mRunning) { Log.w(TAG, "ErrnoException: ", e); } break; } final long whenMs = SystemClock.elapsedRealtime(); Loading @@ -477,7 +470,7 @@ public class IpReachabilityMonitor { clearNetlinkSocket(); synchronized (mLock) { mRunning = false; } mRunning = false; // Not a no-op when ErrnoException happened. if (VDBG) { Log.d(TAG, "Finishing observing thread."); } } Loading