mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2024-11-19 09:50:32 +01:00
Orchid: fix infinite task creation loop when shutting down
This commit is contained in:
parent
5be769d4ca
commit
de3665f734
@ -18,4 +18,6 @@ public interface ConnectionCache {
|
||||
Connection getConnectionTo(Router router, boolean isDirectoryConnection) throws InterruptedException, ConnectionTimeoutException, ConnectionFailedException, ConnectionHandshakeException;
|
||||
|
||||
void close();
|
||||
|
||||
boolean isClosed();
|
||||
}
|
||||
|
@ -142,6 +142,11 @@ public class CircuitCreationTask implements Runnable {
|
||||
}
|
||||
|
||||
private void buildCircuitIfNeeded() {
|
||||
if (connectionCache.isClosed()) {
|
||||
logger.warning("Not building circuits, because connection cache is closed");
|
||||
return;
|
||||
}
|
||||
|
||||
final List<StreamExitRequest> pendingExitStreams = circuitManager.getPendingExitStreams();
|
||||
final List<PredictedPortTarget> predictedPorts = predictor.getPredictedPortTargets();
|
||||
final List<ExitTarget> exitTargets = new ArrayList<ExitTarget>();
|
||||
|
@ -101,6 +101,11 @@ public class ConnectionCacheImpl implements ConnectionCache, DashboardRenderable
|
||||
scheduledExecutor.shutdownNow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isClosed() {
|
||||
return isClosed;
|
||||
}
|
||||
|
||||
public Connection getConnectionTo(Router router, boolean isDirectoryConnection) throws InterruptedException, ConnectionTimeoutException, ConnectionFailedException, ConnectionHandshakeException {
|
||||
if(isClosed) {
|
||||
throw new IllegalStateException("ConnectionCache has been closed");
|
||||
|
Loading…
Reference in New Issue
Block a user