mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-21 07:09:56 +01:00
Interrupt connections outside the lock.
This commit is contained in:
@@ -32,6 +32,7 @@ class ConnectionChooserImpl implements ConnectionChooser {
|
|||||||
@Override
|
@Override
|
||||||
public void addConnection(ContactId c, TransportId t,
|
public void addConnection(ContactId c, TransportId t,
|
||||||
DuplexSyncConnection conn, Priority p) {
|
DuplexSyncConnection conn, Priority p) {
|
||||||
|
DuplexSyncConnection close = null;
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
Key k = new Key(c, t);
|
Key k = new Key(c, t);
|
||||||
Value best = bestConnections.get(k);
|
Value best = bestConnections.get(k);
|
||||||
@@ -39,12 +40,14 @@ class ConnectionChooserImpl implements ConnectionChooser {
|
|||||||
bestConnections.put(k, new Value(conn, p));
|
bestConnections.put(k, new Value(conn, p));
|
||||||
} else if (compare(p.getNonce(), best.priority.getNonce()) > 0) {
|
} else if (compare(p.getNonce(), best.priority.getNonce()) > 0) {
|
||||||
LOG.info("Found a better connection");
|
LOG.info("Found a better connection");
|
||||||
|
close = best.connection;
|
||||||
bestConnections.put(k, new Value(conn, p));
|
bestConnections.put(k, new Value(conn, p));
|
||||||
best.connection.interruptOutgoingSession();
|
} else {
|
||||||
|
LOG.info("Already have a better connection");
|
||||||
|
close = conn;
|
||||||
}
|
}
|
||||||
LOG.info("Already have a better connection");
|
|
||||||
conn.interruptOutgoingSession();
|
|
||||||
}
|
}
|
||||||
|
if (close != null) close.interruptOutgoingSession();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user