mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 19:59:05 +01:00
Don't try to reconnect if the connection was closed cleanly.
This commit is contained in:
@@ -136,7 +136,7 @@ class ConnectionRegistryImpl implements ConnectionRegistry {
|
||||
|
||||
@Override
|
||||
public void unregisterConnection(ContactId c, TransportId t,
|
||||
InterruptibleConnection conn, boolean incoming) {
|
||||
InterruptibleConnection conn, boolean incoming, boolean exception) {
|
||||
if (LOG.isLoggable(INFO)) {
|
||||
if (incoming) LOG.info("Incoming connection unregistered: " + t);
|
||||
else LOG.info("Outgoing connection unregistered: " + t);
|
||||
@@ -148,7 +148,8 @@ class ConnectionRegistryImpl implements ConnectionRegistry {
|
||||
throw new IllegalArgumentException();
|
||||
lastConnection = recs.isEmpty();
|
||||
}
|
||||
eventBus.broadcast(new ConnectionClosedEvent(c, t, incoming));
|
||||
eventBus.broadcast(
|
||||
new ConnectionClosedEvent(c, t, incoming, exception));
|
||||
if (lastConnection) {
|
||||
LOG.info("Contact disconnected");
|
||||
eventBus.broadcast(new ContactDisconnectedEvent(c));
|
||||
@@ -178,8 +179,7 @@ class ConnectionRegistryImpl implements ConnectionRegistry {
|
||||
@Override
|
||||
public Collection<ContactId> getConnectedOrBetterContacts(TransportId t) {
|
||||
synchronized (lock) {
|
||||
List<TransportId> better = betterTransports.get(t);
|
||||
if (better == null) better = emptyList();
|
||||
List<TransportId> better = getBetterTransports(t);
|
||||
List<ContactId> contactIds = new ArrayList<>();
|
||||
for (Entry<ContactId, List<ConnectionRecord>> e :
|
||||
contactConnections.entrySet()) {
|
||||
|
||||
@@ -74,12 +74,13 @@ class IncomingDuplexSyncConnection extends DuplexSyncConnection
|
||||
createIncomingSession(ctx, reader, handler).run();
|
||||
reader.dispose(false, true);
|
||||
interruptOutgoingSession();
|
||||
connectionRegistry.unregisterConnection(contactId, transportId,
|
||||
this, true, false);
|
||||
} catch (DbException | IOException e) {
|
||||
logException(LOG, WARNING, e);
|
||||
onReadError(true);
|
||||
} finally {
|
||||
connectionRegistry.unregisterConnection(contactId, transportId,
|
||||
this, true);
|
||||
this, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -118,12 +118,13 @@ class OutgoingDuplexSyncConnection extends DuplexSyncConnection
|
||||
createIncomingSession(ctx, reader, handler).run();
|
||||
reader.dispose(false, true);
|
||||
interruptOutgoingSession();
|
||||
connectionRegistry.unregisterConnection(contactId, transportId,
|
||||
this, false, false);
|
||||
} catch (DbException | IOException e) {
|
||||
logException(LOG, WARNING, e);
|
||||
onReadError();
|
||||
} finally {
|
||||
connectionRegistry.unregisterConnection(contactId, transportId,
|
||||
this, false);
|
||||
this, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,8 +98,8 @@ class PollerImpl implements Poller, EventListener {
|
||||
ConnectionClosedEvent c = (ConnectionClosedEvent) e;
|
||||
// Reschedule polling, the polling interval may have decreased
|
||||
reschedule(c.getTransportId());
|
||||
if (!c.isIncoming()) {
|
||||
// Connect to the disconnected contact
|
||||
// If an outgoing connection failed, try to reconnect
|
||||
if (!c.isIncoming() && c.isException()) {
|
||||
connectToContact(c.getContactId(), c.getTransportId());
|
||||
}
|
||||
} else if (e instanceof ConnectionOpenedEvent) {
|
||||
|
||||
Reference in New Issue
Block a user