mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-20 14:49:53 +01:00
Shutdown manager (untested on Windows).
This commit is contained in:
@@ -22,7 +22,7 @@ import net.sf.briar.api.transport.TransportConstants;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
public class ConnectionDispatcherImpl implements ConnectionDispatcher {
|
||||
class ConnectionDispatcherImpl implements ConnectionDispatcher {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(ConnectionDispatcherImpl.class.getName());
|
||||
|
||||
@@ -28,6 +28,7 @@ import net.sf.briar.api.db.event.DatabaseEvent;
|
||||
import net.sf.briar.api.db.event.DatabaseListener;
|
||||
import net.sf.briar.api.db.event.RemoteTransportsUpdatedEvent;
|
||||
import net.sf.briar.api.db.event.TransportAddedEvent;
|
||||
import net.sf.briar.api.lifecycle.ShutdownManager;
|
||||
import net.sf.briar.api.protocol.Transport;
|
||||
import net.sf.briar.api.protocol.TransportId;
|
||||
import net.sf.briar.api.protocol.TransportIndex;
|
||||
@@ -46,6 +47,7 @@ DatabaseListener {
|
||||
private final CryptoComponent crypto;
|
||||
private final DatabaseComponent db;
|
||||
private final Executor executor;
|
||||
private final ShutdownManager shutdown;
|
||||
private final Cipher ivCipher; // Locking: this
|
||||
private final Map<Bytes, Context> expected; // Locking: this
|
||||
|
||||
@@ -53,10 +55,11 @@ DatabaseListener {
|
||||
|
||||
@Inject
|
||||
ConnectionRecogniserImpl(CryptoComponent crypto, DatabaseComponent db,
|
||||
Executor executor) {
|
||||
Executor executor, ShutdownManager shutdown) {
|
||||
this.crypto = crypto;
|
||||
this.db = db;
|
||||
this.executor = executor;
|
||||
this.shutdown = shutdown;
|
||||
ivCipher = crypto.getIvCipher();
|
||||
expected = new HashMap<Bytes, Context>();
|
||||
db.addListener(this);
|
||||
@@ -64,8 +67,8 @@ DatabaseListener {
|
||||
|
||||
// Locking: this
|
||||
private void initialise() throws DbException {
|
||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||
@Override
|
||||
assert !initialised;
|
||||
shutdown.addShutdownHook(new Runnable() {
|
||||
public void run() {
|
||||
eraseSecrets();
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ import net.sf.briar.api.transport.ConnectionWriter;
|
||||
import net.sf.briar.api.transport.ConnectionWriterFactory;
|
||||
import net.sf.briar.api.transport.StreamTransportConnection;
|
||||
|
||||
public class IncomingStreamConnection extends StreamConnection {
|
||||
class IncomingStreamConnection extends StreamConnection {
|
||||
|
||||
private final ConnectionContext ctx;
|
||||
private final byte[] encryptedIv;
|
||||
|
||||
@@ -15,7 +15,7 @@ import net.sf.briar.api.transport.ConnectionWriter;
|
||||
import net.sf.briar.api.transport.ConnectionWriterFactory;
|
||||
import net.sf.briar.api.transport.StreamTransportConnection;
|
||||
|
||||
public class OutgoingStreamConnection extends StreamConnection {
|
||||
class OutgoingStreamConnection extends StreamConnection {
|
||||
|
||||
private final TransportIndex transportIndex;
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import net.sf.briar.api.transport.StreamTransportConnection;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
public class StreamConnectionFactoryImpl implements StreamConnectionFactory {
|
||||
class StreamConnectionFactoryImpl implements StreamConnectionFactory {
|
||||
|
||||
private final ConnectionReaderFactory connReaderFactory;
|
||||
private final ConnectionWriterFactory connWriterFactory;
|
||||
|
||||
Reference in New Issue
Block a user