extra check for stopped cache client

pull/34/head
Zlatin Balevsky 2019-12-21 15:56:09 +00:00
parent 22580f002c
commit ba5425c958
1 changed files with 6 additions and 0 deletions

View File

@ -1,5 +1,7 @@
package com.muwire.core.hostcache
import java.util.concurrent.atomic.AtomicBoolean
import com.muwire.core.EventBus
import com.muwire.core.MuWireSettings
import com.muwire.core.connection.ConnectionManager
@ -27,6 +29,7 @@ class CacheClient {
final long interval
final MuWireSettings settings
final Timer timer
private final AtomicBoolean stopped = new AtomicBoolean();
public CacheClient(EventBus eventBus, HostCache cache,
ConnectionManager manager, I2PSession session,
@ -47,9 +50,12 @@ class CacheClient {
void stop() {
timer.cancel()
stopped.set(true)
}
private void queryIfNeeded() {
if (stopped.get())
return
if (!manager.getConnections().isEmpty())
return
if (!cache.getHosts(1).isEmpty())