mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Let the limiter know whether connections closed cleanly.
This commit is contained in:
@@ -45,11 +45,13 @@ interface BluetoothConnectionLimiter {
|
||||
|
||||
/**
|
||||
* Informs the limiter that the given connection has been closed.
|
||||
*
|
||||
* @param exception True if the connection was closed due to an exception.
|
||||
*/
|
||||
void connectionClosed(DuplexTransportConnection conn);
|
||||
void connectionClosed(DuplexTransportConnection conn, boolean exception);
|
||||
|
||||
/**
|
||||
* Informs the limiter that all connections have been closed.
|
||||
* Informs the limiter that the Bluetooth adapter has been disabled.
|
||||
*/
|
||||
void allConnectionsClosed();
|
||||
void bluetoothDisabled();
|
||||
}
|
||||
|
||||
@@ -126,7 +126,8 @@ class BluetoothConnectionLimiterImpl implements BluetoothConnectionLimiter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connectionClosed(DuplexTransportConnection conn) {
|
||||
public void connectionClosed(DuplexTransportConnection conn,
|
||||
boolean exception) {
|
||||
synchronized (lock) {
|
||||
Iterator<ConnectionRecord> it = connections.iterator();
|
||||
while (it.hasNext()) {
|
||||
@@ -141,10 +142,10 @@ class BluetoothConnectionLimiterImpl implements BluetoothConnectionLimiter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void allConnectionsClosed() {
|
||||
public void bluetoothDisabled() {
|
||||
synchronized (lock) {
|
||||
connections.clear();
|
||||
LOG.info("All connections closed");
|
||||
LOG.info("Bluetooth disabled");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ abstract class BluetoothPlugin<SS> implements DuplexPlugin, EventListener {
|
||||
void onAdapterDisabled() {
|
||||
LOG.info("Bluetooth disabled");
|
||||
tryToClose(socket);
|
||||
connectionLimiter.allConnectionsClosed();
|
||||
connectionLimiter.bluetoothDisabled();
|
||||
callback.transportDisabled();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user