- Synchronize StoreJob.sendNext() to avoid dups

- StoreState finals
This commit is contained in:
zzz
2012-02-29 18:49:49 +00:00
parent f61183d2d8
commit 538427c269
2 changed files with 10 additions and 7 deletions

View File

@@ -98,6 +98,8 @@ class StoreJob extends JobImpl {
/** /**
* send the key to the next batch of peers * send the key to the next batch of peers
*
* Synchronized to enforce parallelization limits and prevent dups
*/ */
private void sendNext() { private void sendNext() {
if (_state.completed()) { if (_state.completed()) {
@@ -130,8 +132,9 @@ class StoreJob extends JobImpl {
* the routing table, but making sure no more than PARALLELIZATION are outstanding * the routing table, but making sure no more than PARALLELIZATION are outstanding
* at any time * at any time
* *
* Caller should synchronize to enforce parallelization limits and prevent dups
*/ */
private void continueSending() { private synchronized void continueSending() {
if (_state.completed()) return; if (_state.completed()) return;
int toCheck = getParallelization() - _state.getPending().size(); int toCheck = getParallelization() - _state.getPending().size();
if (toCheck <= 0) { if (toCheck <= 0) {

View File

@@ -14,15 +14,15 @@ import net.i2p.data.Hash;
import net.i2p.router.RouterContext; import net.i2p.router.RouterContext;
/** /**
* * Tracks the state of a StoreJob
*/ */
class StoreState { class StoreState {
private RouterContext _context; private final RouterContext _context;
private Hash _key; private final Hash _key;
private DatabaseEntry _data; private final DatabaseEntry _data;
private final HashSet<Hash> _pendingPeers; private final HashSet<Hash> _pendingPeers;
private Map<Hash, Long> _pendingPeerTimes; private final Map<Hash, Long> _pendingPeerTimes;
private Map<Hash, MessageWrapper.WrappedMessage> _pendingMessages; private final Map<Hash, MessageWrapper.WrappedMessage> _pendingMessages;
private final HashSet<Hash> _successfulPeers; private final HashSet<Hash> _successfulPeers;
//private final HashSet<Hash> _successfulExploratoryPeers; //private final HashSet<Hash> _successfulExploratoryPeers;
private final HashSet<Hash> _failedPeers; private final HashSet<Hash> _failedPeers;