propagate from branch 'i2p.i2p' (head db152f1a9e08e80c7bd3b87735b51800e8f4c46f)

to branch 'i2p.i2p.zzz.dhtsnark' (head 9b08b2f47961167d0fee52b6481895c494d410d6)
This commit is contained in:
zzz
2012-06-24 19:53:20 +00:00
9 changed files with 39 additions and 17 deletions

View File

@ -125,7 +125,7 @@ class PeerCoordinator implements PeerListener
/** partial pieces - lock by synching on wantedPieces - TODO store Requests, not PartialPieces */
private final List<PartialPiece> partialPieces;
private boolean halted = false;
private volatile boolean halted;
private final MagnetState magnetState;
private final CoordinatorListener listener;
@ -429,6 +429,14 @@ class PeerCoordinator implements PeerListener
}
}
/**
* @since 0.9.1
*/
public void restart() {
halted = false;
timer.schedule((CHECK_PERIOD / 2) + _random.nextInt((int) CHECK_PERIOD));
}
public void connected(Peer peer)
{
if (halted)

View File

@ -553,21 +553,14 @@ public class Snark
}
stopped = false;
boolean coordinatorChanged = false;
if (coordinator.halted()) {
// ok, we have already started and stopped, but the coordinator seems a bit annoying to
// restart safely, so lets build a new one to replace the old
coordinator.restart();
if (_peerCoordinatorSet != null)
_peerCoordinatorSet.remove(coordinator);
PeerCoordinator newCoord = new PeerCoordinator(_util, id, infoHash, meta, storage, this, this);
if (_peerCoordinatorSet != null)
_peerCoordinatorSet.add(newCoord);
coordinator = newCoord;
coordinatorChanged = true;
_peerCoordinatorSet.add(coordinator);
}
if (!trackerclient.started() && !coordinatorChanged) {
if (!trackerclient.started()) {
trackerclient.start();
} else if (trackerclient.halted() || coordinatorChanged) {
} else if (trackerclient.halted()) {
if (storage != null) {
try {
storage.reopen(rootDataDir);