* i2psnark: Don't create a new PeerCoordinator after restart, as the

TrackerClient holds on to the old one and that causes it
             to not get peers. Possibly fixes ticket #563.
This commit is contained in:
zzz
2012-06-24 19:26:23 +00:00
parent 1671e3b126
commit ff0bfb9f12
4 changed files with 20 additions and 13 deletions

View File

@ -125,7 +125,7 @@ class PeerCoordinator implements PeerListener
/** partial pieces - lock by synching on wantedPieces - TODO store Requests, not PartialPieces */ /** partial pieces - lock by synching on wantedPieces - TODO store Requests, not PartialPieces */
private final List<PartialPiece> partialPieces; private final List<PartialPiece> partialPieces;
private boolean halted = false; private volatile boolean halted;
private final MagnetState magnetState; private final MagnetState magnetState;
private final CoordinatorListener listener; 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) public void connected(Peer peer)
{ {
if (halted) if (halted)

View File

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

View File

@ -1,4 +1,10 @@
2012-06-24 zzz 2012-06-24 zzz
* ElGamalAESEngine: Fix bad size estimate when tags are included,
resulting in trailing zeros after the padding
in the unencrypted data
* i2psnark: Don't create a new PeerCoordinator after restart, as the
TrackerClient holds on to the old one and that causes it
to not get peers. Possibly fixes ticket #563.
* I2PTunnel: Fix NPE on shared client creation, thx kytv * I2PTunnel: Fix NPE on shared client creation, thx kytv
* Transport: Add Ethiopia to hidden mode list * Transport: Add Ethiopia to hidden mode list

View File

@ -18,7 +18,7 @@ public class RouterVersion {
/** deprecated */ /** deprecated */
public final static String ID = "Monotone"; public final static String ID = "Monotone";
public final static String VERSION = CoreVersion.VERSION; public final static String VERSION = CoreVersion.VERSION;
public final static long BUILD = 18; public final static long BUILD = 19;
/** for example "-test" */ /** for example "-test" */
public final static String EXTRA = ""; public final static String EXTRA = "";