mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 02:39:05 +01:00
cleanup
This commit is contained in:
@@ -58,12 +58,12 @@ Service, EventListener {
|
||||
private final EventBus eventBus;
|
||||
private final Context appContext;
|
||||
private final Map<ContactId, Integer> contactCounts =
|
||||
new HashMap<ContactId, Integer>(); // Locking: this
|
||||
new HashMap<ContactId, Integer>();
|
||||
private final Map<GroupId, Integer> groupCounts =
|
||||
new HashMap<GroupId, Integer>(); // Locking: this
|
||||
new HashMap<GroupId, Integer>();
|
||||
|
||||
private int privateTotal = 0, groupTotal = 0; // Locking: this
|
||||
private int nextRequestId = 0; // Locking: this
|
||||
private int privateTotal = 0, groupTotal = 0;
|
||||
private int nextRequestId = 0;
|
||||
|
||||
private volatile Settings settings = new Settings();
|
||||
|
||||
@@ -134,7 +134,6 @@ Service, EventListener {
|
||||
}
|
||||
}
|
||||
|
||||
// Locking: this
|
||||
private void updatePrivateMessageNotification() {
|
||||
if(privateTotal == 0) {
|
||||
clearPrivateMessageNotification();
|
||||
@@ -178,7 +177,6 @@ Service, EventListener {
|
||||
}
|
||||
}
|
||||
|
||||
// Locking: this
|
||||
private void clearPrivateMessageNotification() {
|
||||
Object o = appContext.getSystemService(NOTIFICATION_SERVICE);
|
||||
NotificationManager nm = (NotificationManager) o;
|
||||
@@ -223,7 +221,6 @@ Service, EventListener {
|
||||
}
|
||||
}
|
||||
|
||||
// Locking: this
|
||||
private void updateGroupPostNotification() {
|
||||
if(groupTotal == 0) {
|
||||
clearGroupPostNotification();
|
||||
|
||||
@@ -18,7 +18,7 @@ class ReferenceManagerImpl implements ReferenceManager {
|
||||
private final Map<Class<?>, Map<Long, Object>> outerMap =
|
||||
new HashMap<Class<?>, Map<Long, Object>>();
|
||||
|
||||
private long nextHandle = 0; // Locking: this
|
||||
private long nextHandle = 0;
|
||||
|
||||
private final Lock synchLock = new ReentrantLock();
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ class FortunaGenerator {
|
||||
private static final int KEY_BYTES = 32;
|
||||
private static final int BLOCK_BYTES = 16;
|
||||
|
||||
// All of the following are locking: this
|
||||
private final MessageDigest digest = new DoubleDigest(new SHA256Digest());
|
||||
private final BlockCipher cipher = new AESLightEngine();
|
||||
private final byte[] key = new byte[KEY_BYTES];
|
||||
|
||||
@@ -10,7 +10,7 @@ class SecretKeyImpl implements SecretKey {
|
||||
|
||||
private final byte[] key;
|
||||
|
||||
private boolean erased = false; // Locking: this
|
||||
private boolean erased = false;
|
||||
|
||||
private final Lock synchLock = new ReentrantLock();
|
||||
|
||||
|
||||
@@ -316,12 +316,12 @@ abstract class JdbcDatabase implements Database<Connection> {
|
||||
private final Clock clock;
|
||||
|
||||
private final LinkedList<Connection> connections =
|
||||
new LinkedList<Connection>(); // Locking: self
|
||||
new LinkedList<Connection>();
|
||||
|
||||
private final AtomicInteger transactionCount = new AtomicInteger(0);
|
||||
|
||||
private int openConnections = 0; // Locking: connections
|
||||
private boolean closed = false; // Locking: connections
|
||||
private int openConnections = 0;
|
||||
private boolean closed = false;
|
||||
|
||||
protected abstract Connection createConnection() throws SQLException;
|
||||
protected abstract void flushBuffersToDisk(Statement s) throws SQLException;
|
||||
|
||||
@@ -65,10 +65,7 @@ class ConnectorGroup extends Thread implements InvitationTask {
|
||||
|
||||
private final Lock synchLock = new ReentrantLock();
|
||||
|
||||
/*
|
||||
* All of the following require locking: this. We don't want to call the
|
||||
* listeners with a lock held, but we need to avoid a race condition in
|
||||
* addListener(), so the state that's accessed in addListener() after
|
||||
/*The state that's accessed in addListener() after
|
||||
* calling listeners.add() must be guarded by a lock.
|
||||
*/
|
||||
private int localConfirmationCode = -1, remoteConfirmationCode = -1;
|
||||
|
||||
@@ -9,9 +9,9 @@ import org.briarproject.api.lifecycle.ShutdownManager;
|
||||
|
||||
class ShutdownManagerImpl implements ShutdownManager {
|
||||
|
||||
protected final Map<Integer, Thread> hooks; // Locking: this
|
||||
protected final Map<Integer, Thread> hooks;
|
||||
|
||||
private int nextHandle = 0; // Locking: this
|
||||
private int nextHandle = 0;
|
||||
|
||||
private final Lock synchLock = new ReentrantLock();
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ class Receiver implements ReadHandler {
|
||||
|
||||
private final Clock clock;
|
||||
private final Sender sender;
|
||||
private final SortedSet<Data> dataFrames; // Locking: this
|
||||
private final SortedSet<Data> dataFrames;
|
||||
|
||||
private int windowSize = MAX_WINDOW_SIZE; // Locking: this
|
||||
private int windowSize = MAX_WINDOW_SIZE;
|
||||
private long finalSequenceNumber = Long.MAX_VALUE;
|
||||
private long nextSequenceNumber = 1;
|
||||
|
||||
|
||||
@@ -25,9 +25,8 @@ class Sender {
|
||||
|
||||
private final Clock clock;
|
||||
private final WriteHandler writeHandler;
|
||||
private final LinkedList<Outstanding> outstanding; // Locking: this
|
||||
private final LinkedList<Outstanding> outstanding;
|
||||
|
||||
// All of the following are locking: this
|
||||
private int outstandingBytes = 0;
|
||||
private int windowSize = Data.MAX_PAYLOAD_LENGTH;
|
||||
private int rtt = INITIAL_RTT, rttVar = INITIAL_RTT_VAR;
|
||||
|
||||
@@ -52,7 +52,6 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
|
||||
private final Clock clock;
|
||||
private final Timer timer;
|
||||
|
||||
// All of the following are locking: this
|
||||
private final Map<TransportId, Long> maxLatencies;
|
||||
private final Map<EndpointKey, TemporarySecret> oldSecrets;
|
||||
private final Map<EndpointKey, TemporarySecret> currentSecrets;
|
||||
@@ -120,7 +119,6 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
|
||||
}
|
||||
|
||||
// Assigns secrets to the appropriate maps and returns any dead secrets
|
||||
// Locking: this
|
||||
private Collection<TemporarySecret> assignSecretsToMaps(long now,
|
||||
Collection<TemporarySecret> secrets) {
|
||||
Collection<TemporarySecret> dead = new ArrayList<TemporarySecret>();
|
||||
@@ -154,7 +152,6 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
|
||||
}
|
||||
|
||||
// Replaces and erases the given secrets and returns any secrets created
|
||||
// Locking: this
|
||||
private Collection<TemporarySecret> replaceDeadSecrets(long now,
|
||||
Collection<TemporarySecret> dead) {
|
||||
// If there are several dead secrets for an endpoint, use the newest
|
||||
@@ -242,7 +239,6 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
|
||||
}
|
||||
}
|
||||
|
||||
// Locking: this
|
||||
private void removeAndEraseSecrets(Map<?, TemporarySecret> m) {
|
||||
for(TemporarySecret s : m.values()) ByteUtils.erase(s.getSecret());
|
||||
m.clear();
|
||||
@@ -374,7 +370,6 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
|
||||
}
|
||||
}
|
||||
|
||||
// Locking: this
|
||||
private void removeAndEraseSecrets(ContactId c, Map<?, TemporarySecret> m) {
|
||||
Iterator<TemporarySecret> it = m.values().iterator();
|
||||
while(it.hasNext()) {
|
||||
@@ -386,7 +381,6 @@ class KeyManagerImpl extends TimerTask implements KeyManager, EventListener {
|
||||
}
|
||||
}
|
||||
|
||||
// Locking: this
|
||||
private void removeAndEraseSecrets(TransportId t,
|
||||
Map<?, TemporarySecret> m) {
|
||||
Iterator<TemporarySecret> it = m.values().iterator();
|
||||
|
||||
@@ -20,7 +20,7 @@ class TagRecogniserImpl implements TagRecogniser {
|
||||
|
||||
private final CryptoComponent crypto;
|
||||
private final DatabaseComponent db;
|
||||
// Locking: this
|
||||
|
||||
private final Map<TransportId, TransportTagRecogniser> recognisers;
|
||||
|
||||
private final Lock synchLock = new ReentrantLock();
|
||||
|
||||
@@ -29,8 +29,8 @@ class TransportTagRecogniser {
|
||||
private final CryptoComponent crypto;
|
||||
private final DatabaseComponent db;
|
||||
private final TransportId transportId;
|
||||
private final Map<Bytes, TagContext> tagMap; // Locking: this
|
||||
private final Map<RemovalKey, RemovalContext> removalMap; // Locking: this
|
||||
private final Map<Bytes, TagContext> tagMap;
|
||||
private final Map<RemovalKey, RemovalContext> removalMap;
|
||||
|
||||
private final Lock synchLock = new ReentrantLock();
|
||||
|
||||
@@ -119,7 +119,6 @@ class TransportTagRecogniser {
|
||||
}
|
||||
}
|
||||
|
||||
// Locking: this
|
||||
private void removeSecret(RemovalContext r) {
|
||||
// Remove the expected tags
|
||||
SecretKey key = crypto.deriveTagKey(r.secret, !r.alice);
|
||||
|
||||
@@ -39,7 +39,7 @@ class WindowsShutdownManagerImpl extends ShutdownManagerImpl {
|
||||
|
||||
private final Map<String, Object> options;
|
||||
|
||||
private boolean initialised = false; // Locking: this
|
||||
private boolean initialised = false;
|
||||
|
||||
private final Lock synchLock = new ReentrantLock();
|
||||
|
||||
@@ -69,7 +69,6 @@ class WindowsShutdownManagerImpl extends ShutdownManagerImpl {
|
||||
return new StartOnce(r);
|
||||
}
|
||||
|
||||
// Locking: this
|
||||
private void initialise() {
|
||||
if(OsUtils.isWindows()) {
|
||||
new EventLoop().start();
|
||||
|
||||
@@ -14,14 +14,13 @@ import net.contentobjects.jnotify.JNotifyListener;
|
||||
abstract class UnixRemovableDriveMonitor implements RemovableDriveMonitor,
|
||||
JNotifyListener {
|
||||
|
||||
private static boolean triedLoad = false; // Locking: class
|
||||
private static Throwable loadError = null; // Locking: class
|
||||
private static boolean triedLoad = false;
|
||||
private static Throwable loadError = null;
|
||||
|
||||
// Locking: this
|
||||
private final List<Integer> watches = new ArrayList<Integer>();
|
||||
|
||||
private boolean started = false; // Locking: this
|
||||
private Callback callback = null; // Locking: this
|
||||
private boolean started = false;
|
||||
private Callback callback = null;
|
||||
|
||||
protected abstract String[] getPathsToWatch();
|
||||
|
||||
|
||||
@@ -46,8 +46,8 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
|
||||
|
||||
private int lineLen = 0;
|
||||
|
||||
private ReliabilityLayer reliability = null; // Locking: this
|
||||
private boolean initialised = false, connected = false; // Locking: this
|
||||
private ReliabilityLayer reliability = null;
|
||||
private boolean initialised = false, connected = false;
|
||||
|
||||
private final Lock synchLock = new ReentrantLock();
|
||||
private final Condition connectedStateChanged = synchLock.newCondition();
|
||||
@@ -163,7 +163,6 @@ class ModemImpl implements Modem, WriteHandler, SerialPortEventListener {
|
||||
}
|
||||
}
|
||||
|
||||
// Locking: stateChange
|
||||
private void hangUpInner() throws IOException {
|
||||
ReliabilityLayer reliability;
|
||||
synchLock.lock();
|
||||
|
||||
Reference in New Issue
Block a user