shutdown all connections on shutdown
This commit is contained in:
@@ -69,6 +69,7 @@ public class Core {
|
||||
private final ConnectionAcceptor connectionAcceptor
|
||||
private final ConnectionEstablisher connectionEstablisher
|
||||
private final HasherService hasherService
|
||||
private final DownloadManager downloadManager
|
||||
|
||||
public Core(MuWireSettings props, File home, String myVersion) {
|
||||
this.home = home
|
||||
@@ -195,7 +196,7 @@ public class Core {
|
||||
eventBus.register(ResultsEvent.class, searchManager)
|
||||
|
||||
log.info("initializing download manager")
|
||||
DownloadManager downloadManager = new DownloadManager(eventBus, i2pConnector, home, me)
|
||||
downloadManager = new DownloadManager(eventBus, i2pConnector, home, me)
|
||||
eventBus.register(UIDownloadEvent.class, downloadManager)
|
||||
eventBus.register(UILoadedEvent.class, downloadManager)
|
||||
eventBus.register(FileDownloadedEvent.class, downloadManager)
|
||||
@@ -234,6 +235,9 @@ public class Core {
|
||||
|
||||
public void shutdown() {
|
||||
connectionManager.shutdown()
|
||||
downloadManager.shutdown()
|
||||
connectionAcceptor.stop()
|
||||
connectionEstablisher.stop()
|
||||
}
|
||||
|
||||
static main(args) {
|
||||
|
||||
@@ -135,4 +135,8 @@ public class DownloadManager {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
downloaders.each { it.stop() }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,11 +169,15 @@ public class Downloader {
|
||||
|
||||
public void cancel() {
|
||||
cancelled = true
|
||||
stop()
|
||||
file.delete()
|
||||
piecesFile.delete()
|
||||
}
|
||||
|
||||
void stop() {
|
||||
activeWorkers.values().each {
|
||||
it.cancel()
|
||||
}
|
||||
file.delete()
|
||||
piecesFile.delete()
|
||||
}
|
||||
|
||||
public int activeWorkers() {
|
||||
|
||||
Reference in New Issue
Block a user