mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-16 04:39:54 +01:00
Don't try to close server sockets twice.
This may have been the cause of bug #69. Removed the wait-for-shutdown code in DroidtoothPlugin that was added to attempt to avoid that bug.
This commit is contained in:
@@ -207,7 +207,6 @@ class DroidtoothPlugin implements DuplexPlugin {
|
|||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
// This is expected when the socket is closed
|
// This is expected when the socket is closed
|
||||||
if(LOG.isLoggable(INFO)) LOG.info(e.toString());
|
if(LOG.isLoggable(INFO)) LOG.info(e.toString());
|
||||||
tryToClose(socket);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(LOG.isLoggable(INFO)) {
|
if(LOG.isLoggable(INFO)) {
|
||||||
@@ -228,18 +227,8 @@ class DroidtoothPlugin implements DuplexPlugin {
|
|||||||
tryToClose(socket);
|
tryToClose(socket);
|
||||||
// Disable Bluetooth if we enabled it and it's still enabled
|
// Disable Bluetooth if we enabled it and it's still enabled
|
||||||
if(wasDisabled && adapter.isEnabled()) {
|
if(wasDisabled && adapter.isEnabled()) {
|
||||||
// Try to disable the adapter and wait for the result
|
if(adapter.disable()) LOG.info("Disabling Bluetooth");
|
||||||
LOG.info("Disabling Bluetooth");
|
else LOG.info("Could not disable Bluetooth");
|
||||||
IntentFilter filter = new IntentFilter(ACTION_STATE_CHANGED);
|
|
||||||
DisableBluetoothReceiver receiver = new DisableBluetoothReceiver();
|
|
||||||
appContext.registerReceiver(receiver, filter);
|
|
||||||
if(adapter.disable()) {
|
|
||||||
LOG.info("Disabling Bluetooth");
|
|
||||||
receiver.waitForStateChange();
|
|
||||||
} else {
|
|
||||||
LOG.info("Could not disable Bluetooth");
|
|
||||||
}
|
|
||||||
appContext.unregisterReceiver(receiver);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -392,28 +381,6 @@ class DroidtoothPlugin implements DuplexPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DisableBluetoothReceiver extends BroadcastReceiver {
|
|
||||||
|
|
||||||
private final CountDownLatch latch = new CountDownLatch(1);
|
|
||||||
|
|
||||||
public void onReceive(Context ctx, Intent intent) {
|
|
||||||
int state = intent.getIntExtra(EXTRA_STATE, 0);
|
|
||||||
if(state == STATE_OFF) {
|
|
||||||
LOG.info("Bluetooth disabled");
|
|
||||||
latch.countDown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void waitForStateChange() {
|
|
||||||
try {
|
|
||||||
latch.await();
|
|
||||||
} catch(InterruptedException e) {
|
|
||||||
LOG.info("Interrupted while disabling Bluetooth");
|
|
||||||
Thread.currentThread().interrupt();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DiscoveryThread extends Thread {
|
private class DiscoveryThread extends Thread {
|
||||||
|
|
||||||
private final LatchedReference<BluetoothSocket> socketLatch;
|
private final LatchedReference<BluetoothSocket> socketLatch;
|
||||||
|
|||||||
@@ -534,7 +534,6 @@ class TorPlugin implements DuplexPlugin, EventHandler {
|
|||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
// This is expected when the socket is closed
|
// This is expected when the socket is closed
|
||||||
if(LOG.isLoggable(INFO)) LOG.info(e.toString());
|
if(LOG.isLoggable(INFO)) LOG.info(e.toString());
|
||||||
tryToClose(ss);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LOG.info("Connection received");
|
LOG.info("Connection received");
|
||||||
|
|||||||
@@ -139,7 +139,6 @@ abstract class TcpPlugin implements DuplexPlugin {
|
|||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
// This is expected when the socket is closed
|
// This is expected when the socket is closed
|
||||||
if(LOG.isLoggable(INFO)) LOG.info(e.toString());
|
if(LOG.isLoggable(INFO)) LOG.info(e.toString());
|
||||||
tryToClose(socket);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(LOG.isLoggable(INFO))
|
if(LOG.isLoggable(INFO))
|
||||||
|
|||||||
@@ -157,7 +157,6 @@ class BluetoothPlugin implements DuplexPlugin {
|
|||||||
} catch(IOException e) {
|
} catch(IOException e) {
|
||||||
// This is expected when the socket is closed
|
// This is expected when the socket is closed
|
||||||
if(LOG.isLoggable(INFO)) LOG.info(e.toString());
|
if(LOG.isLoggable(INFO)) LOG.info(e.toString());
|
||||||
tryToClose(ss);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
callback.incomingConnectionCreated(wrapSocket(s));
|
callback.incomingConnectionCreated(wrapSocket(s));
|
||||||
|
|||||||
Reference in New Issue
Block a user