mirror of https://github.com/zlatinb/muwire
prevent exception on shutodwn reported in GitHub issue #157
parent
e690a2f124
commit
b04179631c
|
@ -29,6 +29,7 @@ class H2HostCache extends HostCache {
|
||||||
private final Map<Destination, HostMCProfile> profiles = new HashMap<>()
|
private final Map<Destination, HostMCProfile> profiles = new HashMap<>()
|
||||||
|
|
||||||
private final Timer timer
|
private final Timer timer
|
||||||
|
private boolean closed
|
||||||
|
|
||||||
private Collection<Destination> toVerify = new LinkedHashSet<>()
|
private Collection<Destination> toVerify = new LinkedHashSet<>()
|
||||||
|
|
||||||
|
@ -302,6 +303,7 @@ class H2HostCache extends HostCache {
|
||||||
public synchronized void stop() {
|
public synchronized void stop() {
|
||||||
try {timer.cancel()} catch (Exception ignore) {}
|
try {timer.cancel()} catch (Exception ignore) {}
|
||||||
sql?.close()
|
sql?.close()
|
||||||
|
closed = true
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public synchronized void load() {
|
public synchronized void load() {
|
||||||
|
@ -346,14 +348,20 @@ class H2HostCache extends HostCache {
|
||||||
|
|
||||||
log.fine("loaded ${allHosts.size()} hosts from db")
|
log.fine("loaded ${allHosts.size()} hosts from db")
|
||||||
timer.schedule({
|
timer.schedule({
|
||||||
recycleSQL()
|
houseKeep()
|
||||||
purgeHopeless()
|
|
||||||
verifyHosts()
|
|
||||||
recordConnectionCount()
|
|
||||||
} as TimerTask, 60000, 60000)
|
} as TimerTask, 60000, 60000)
|
||||||
loaded = true
|
loaded = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private synchronized void houseKeep() {
|
||||||
|
if (closed)
|
||||||
|
return
|
||||||
|
recycleSQL()
|
||||||
|
purgeHopeless()
|
||||||
|
verifyHosts()
|
||||||
|
recordConnectionCount()
|
||||||
|
}
|
||||||
|
|
||||||
private synchronized void verifyHosts() {
|
private synchronized void verifyHosts() {
|
||||||
log.fine("starting verification")
|
log.fine("starting verification")
|
||||||
final long now = System.currentTimeMillis()
|
final long now = System.currentTimeMillis()
|
||||||
|
|
Loading…
Reference in New Issue