mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 11:49:04 +01:00
Let the limiter know whether connections closed cleanly.
This commit is contained in:
@@ -50,7 +50,7 @@ class AndroidBluetoothTransportConnection
|
|||||||
try {
|
try {
|
||||||
socket.close();
|
socket.close();
|
||||||
} finally {
|
} finally {
|
||||||
connectionLimiter.connectionClosed(this);
|
connectionLimiter.connectionClosed(this, exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,11 +45,13 @@ interface BluetoothConnectionLimiter {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Informs the limiter that the given connection has been closed.
|
* 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
|
@Override
|
||||||
public void connectionClosed(DuplexTransportConnection conn) {
|
public void connectionClosed(DuplexTransportConnection conn,
|
||||||
|
boolean exception) {
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
Iterator<ConnectionRecord> it = connections.iterator();
|
Iterator<ConnectionRecord> it = connections.iterator();
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
@@ -141,10 +142,10 @@ class BluetoothConnectionLimiterImpl implements BluetoothConnectionLimiter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void allConnectionsClosed() {
|
public void bluetoothDisabled() {
|
||||||
synchronized (lock) {
|
synchronized (lock) {
|
||||||
connections.clear();
|
connections.clear();
|
||||||
LOG.info("All connections closed");
|
LOG.info("Bluetooth disabled");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ abstract class BluetoothPlugin<SS> implements DuplexPlugin, EventListener {
|
|||||||
void onAdapterDisabled() {
|
void onAdapterDisabled() {
|
||||||
LOG.info("Bluetooth disabled");
|
LOG.info("Bluetooth disabled");
|
||||||
tryToClose(socket);
|
tryToClose(socket);
|
||||||
connectionLimiter.allConnectionsClosed();
|
connectionLimiter.bluetoothDisabled();
|
||||||
callback.transportDisabled();
|
callback.transportDisabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ class JavaBluetoothTransportConnection
|
|||||||
try {
|
try {
|
||||||
stream.close();
|
stream.close();
|
||||||
} finally {
|
} finally {
|
||||||
connectionLimiter.connectionClosed(this);
|
connectionLimiter.connectionClosed(this, exception);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user