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

Commit f9ee0e50 authored by Paul Jensen's avatar Paul Jensen
Browse files

Remove needless locking of mRulesLock that caused deadlocks.

The locks were added in c006f1 when underlying functions weren't performing
locking.  In d2a45875 the underlying functions were changed to perform locking
but the higher level locking wasn't removed.  The higher level locking can
now cause deadlocks with the new NetworkAgentInfo locking.  This change
removes the needless higher level locking.  Now all mRulesLock locking
only guards simple accesses to the appropriate two data strucures so there is
no chance of a deadlock.  I verified that all accesses to the appropriate
two data structures are guarded by mRulesLock locking.

bug:17569997
Change-Id: Id9f4e3d19d6895876925ae32f12460db30359368
parent f5194d8c
Loading
Loading
Loading
Loading
+13 −16
Original line number Original line Diff line number Diff line
@@ -979,14 +979,12 @@ public class ConnectivityService extends IConnectivityManager.Stub {
        enforceAccessPermission();
        enforceAccessPermission();
        final int uid = Binder.getCallingUid();
        final int uid = Binder.getCallingUid();
        final ArrayList<NetworkInfo> result = Lists.newArrayList();
        final ArrayList<NetworkInfo> result = Lists.newArrayList();
        synchronized (mRulesLock) {
        for (int networkType = 0; networkType <= ConnectivityManager.MAX_NETWORK_TYPE;
        for (int networkType = 0; networkType <= ConnectivityManager.MAX_NETWORK_TYPE;
                networkType++) {
                networkType++) {
            if (getNetworkInfoForType(networkType) != null) {
            if (getNetworkInfoForType(networkType) != null) {
                result.add(getFilteredNetworkInfo(networkType, uid));
                result.add(getFilteredNetworkInfo(networkType, uid));
            }
            }
        }
        }
        }
        return result.toArray(new NetworkInfo[result.size()]);
        return result.toArray(new NetworkInfo[result.size()]);
    }
    }


@@ -1078,7 +1076,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
        enforceAccessPermission();
        enforceAccessPermission();
        final int uid = Binder.getCallingUid();
        final int uid = Binder.getCallingUid();
        final ArrayList<NetworkState> result = Lists.newArrayList();
        final ArrayList<NetworkState> result = Lists.newArrayList();
        synchronized (mRulesLock) {
        for (int networkType = 0; networkType <= ConnectivityManager.MAX_NETWORK_TYPE;
        for (int networkType = 0; networkType <= ConnectivityManager.MAX_NETWORK_TYPE;
                networkType++) {
                networkType++) {
            if (getNetworkInfoForType(networkType) != null) {
            if (getNetworkInfoForType(networkType) != null) {
@@ -1088,7 +1085,6 @@ public class ConnectivityService extends IConnectivityManager.Stub {
                result.add(new NetworkState(info, lp, netcap));
                result.add(new NetworkState(info, lp, netcap));
            }
            }
        }
        }
        }
        return result.toArray(new NetworkState[result.size()]);
        return result.toArray(new NetworkState[result.size()]);
    }
    }


@@ -4125,8 +4121,9 @@ public class ConnectivityService extends IConnectivityManager.Stub {
        if (networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED)
        if (networkCapabilities.hasCapability(NetworkCapabilities.NET_CAPABILITY_NOT_METERED)
                == false) {
                == false) {
            final int uidRules;
            final int uidRules;
            final int uid = Binder.getCallingUid();
            synchronized(mRulesLock) {
            synchronized(mRulesLock) {
                uidRules = mUidRules.get(Binder.getCallingUid(), RULE_ALLOW_ALL);
                uidRules = mUidRules.get(uid, RULE_ALLOW_ALL);
            }
            }
            if ((uidRules & RULE_REJECT_METERED) != 0) {
            if ((uidRules & RULE_REJECT_METERED) != 0) {
                // we could silently fail or we can filter the available nets to only give
                // we could silently fail or we can filter the available nets to only give