forked from I2P_Developers/i2p.i2p
- Synchronize StoreJob.sendNext() to avoid dups
- StoreState finals
This commit is contained in:
@@ -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) {
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
Reference in New Issue
Block a user