IpSecService - Convert mNextResourceId from AtomicInt to Int
The mNextResourceId variable is only accessed within synchronized blocks, so there is no need to use an atomic integer to synchronize it. This eliminates the misleading notion that the variable is accessed outside of guarded blocks, which it is not. Bug: 62279167 Test: cts Change-Id: I815835622659f54d2d2d33b349b17c632ebced8d
This commit is contained in:
@@ -102,8 +102,14 @@ public class IpSecService extends IIpSecService.Stub {
|
|||||||
/* Binder context for this service */
|
/* Binder context for this service */
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
|
|
||||||
/** Should be a never-repeating global ID for resources */
|
/**
|
||||||
private static AtomicInteger mNextResourceId = new AtomicInteger(0x00FADED0);
|
* The next non-repeating global ID for tracking resources between users, this service,
|
||||||
|
* and kernel data structures. Accessing this variable is not thread safe, so it is
|
||||||
|
* only read or modified within blocks synchronized on IpSecService.this. We want to
|
||||||
|
* avoid -1 (INVALID_RESOURCE_ID) and 0 (we probably forgot to initialize it).
|
||||||
|
*/
|
||||||
|
@GuardedBy("IpSecService.this")
|
||||||
|
private int mNextResourceId = 1;
|
||||||
|
|
||||||
interface IpSecServiceConfiguration {
|
interface IpSecServiceConfiguration {
|
||||||
INetd getNetdInstance() throws RemoteException;
|
INetd getNetdInstance() throws RemoteException;
|
||||||
@@ -856,7 +862,7 @@ public class IpSecService extends IIpSecService.Stub {
|
|||||||
checkNotNull(binder, "Null Binder passed to allocateSecurityParameterIndex");
|
checkNotNull(binder, "Null Binder passed to allocateSecurityParameterIndex");
|
||||||
|
|
||||||
UserRecord userRecord = mUserResourceTracker.getUserRecord(Binder.getCallingUid());
|
UserRecord userRecord = mUserResourceTracker.getUserRecord(Binder.getCallingUid());
|
||||||
int resourceId = mNextResourceId.getAndIncrement();
|
final int resourceId = mNextResourceId++;
|
||||||
|
|
||||||
int spi = IpSecManager.INVALID_SECURITY_PARAMETER_INDEX;
|
int spi = IpSecManager.INVALID_SECURITY_PARAMETER_INDEX;
|
||||||
String localAddress = "";
|
String localAddress = "";
|
||||||
@@ -979,7 +985,7 @@ public class IpSecService extends IIpSecService.Stub {
|
|||||||
|
|
||||||
int callingUid = Binder.getCallingUid();
|
int callingUid = Binder.getCallingUid();
|
||||||
UserRecord userRecord = mUserResourceTracker.getUserRecord(callingUid);
|
UserRecord userRecord = mUserResourceTracker.getUserRecord(callingUid);
|
||||||
int resourceId = mNextResourceId.getAndIncrement();
|
final int resourceId = mNextResourceId++;
|
||||||
FileDescriptor sockFd = null;
|
FileDescriptor sockFd = null;
|
||||||
try {
|
try {
|
||||||
if (!userRecord.mSocketQuotaTracker.isAvailable()) {
|
if (!userRecord.mSocketQuotaTracker.isAvailable()) {
|
||||||
@@ -1102,7 +1108,7 @@ public class IpSecService extends IIpSecService.Stub {
|
|||||||
IpSecConfig c, IBinder binder) throws RemoteException {
|
IpSecConfig c, IBinder binder) throws RemoteException {
|
||||||
checkIpSecConfig(c);
|
checkIpSecConfig(c);
|
||||||
checkNotNull(binder, "Null Binder passed to createTransportModeTransform");
|
checkNotNull(binder, "Null Binder passed to createTransportModeTransform");
|
||||||
int resourceId = mNextResourceId.getAndIncrement();
|
final int resourceId = mNextResourceId++;
|
||||||
|
|
||||||
UserRecord userRecord = mUserResourceTracker.getUserRecord(Binder.getCallingUid());
|
UserRecord userRecord = mUserResourceTracker.getUserRecord(Binder.getCallingUid());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user