mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 21:29:54 +01:00
Ensure TimeoutInputStreams are closed.
This commit is contained in:
@@ -55,6 +55,7 @@ class AndroidBluetoothTransportConnection
|
|||||||
protected void closeConnection(boolean exception) throws IOException {
|
protected void closeConnection(boolean exception) throws IOException {
|
||||||
try {
|
try {
|
||||||
socket.close();
|
socket.close();
|
||||||
|
in.close();
|
||||||
} finally {
|
} finally {
|
||||||
wakeLock.release();
|
wakeLock.release();
|
||||||
connectionLimiter.connectionClosed(this);
|
connectionLimiter.connectionClosed(this);
|
||||||
|
|||||||
@@ -7,6 +7,10 @@ public interface TimeoutMonitor {
|
|||||||
/**
|
/**
|
||||||
* Returns an {@link InputStream} that wraps the given stream and allows
|
* Returns an {@link InputStream} that wraps the given stream and allows
|
||||||
* read timeouts to be detected.
|
* read timeouts to be detected.
|
||||||
|
* <p>
|
||||||
|
* The returned stream must be {@link InputStream#close() closed} when it's
|
||||||
|
* no longer needed to ensure that resources held by the timeout monitor
|
||||||
|
* are released.
|
||||||
*
|
*
|
||||||
* @param timeoutMs The read timeout in milliseconds. Timeouts will be
|
* @param timeoutMs The read timeout in milliseconds. Timeouts will be
|
||||||
* detected eventually but are not guaranteed to be detected immediately.
|
* detected eventually but are not guaranteed to be detected immediately.
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ class JavaBluetoothTransportConnection
|
|||||||
protected void closeConnection(boolean exception) throws IOException {
|
protected void closeConnection(boolean exception) throws IOException {
|
||||||
try {
|
try {
|
||||||
socket.close();
|
socket.close();
|
||||||
|
in.close();
|
||||||
} finally {
|
} finally {
|
||||||
connectionLimiter.connectionClosed(this);
|
connectionLimiter.connectionClosed(this);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user