mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-18 13:49:53 +01:00
Check that poller instance isn't reused.
This commit is contained in:
@@ -47,6 +47,7 @@ import java.util.Map;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@@ -79,6 +80,7 @@ class RendezvousPollerImpl implements RendezvousPoller, Service, EventListener {
|
|||||||
private final EventBus eventBus;
|
private final EventBus eventBus;
|
||||||
private final Clock clock;
|
private final Clock clock;
|
||||||
|
|
||||||
|
private final AtomicBoolean used = new AtomicBoolean(false);
|
||||||
// Executor that runs one task at a time
|
// Executor that runs one task at a time
|
||||||
private final Executor worker;
|
private final Executor worker;
|
||||||
// The following fields are only accessed on the worker
|
// The following fields are only accessed on the worker
|
||||||
@@ -113,6 +115,7 @@ class RendezvousPollerImpl implements RendezvousPoller, Service, EventListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void startService() throws ServiceException {
|
public void startService() throws ServiceException {
|
||||||
|
if (used.getAndSet(true)) throw new IllegalStateException();
|
||||||
try {
|
try {
|
||||||
db.transaction(true, txn -> {
|
db.transaction(true, txn -> {
|
||||||
Collection<PendingContact> pending = db.getPendingContacts(txn);
|
Collection<PendingContact> pending = db.getPendingContacts(txn);
|
||||||
|
|||||||
Reference in New Issue
Block a user