* Tunnel Pool:

- Clean up some tunnel removal code
  - Don't try to build a LeaseSet with more than 6 leases,
    no matter what the setting
This commit is contained in:
zzz
2009-04-26 18:32:57 +00:00
parent a279f8d530
commit c9b6d72c5a
2 changed files with 15 additions and 4 deletions

View File

@ -67,7 +67,7 @@ public class LeaseSet extends DataStructureImpl {
private boolean _checked;
/** This seems like plenty */
private final static int MAX_LEASES = 6;
public final static int MAX_LEASES = 6;
public LeaseSet() {
setDestination(null);

View File

@ -65,6 +65,9 @@ public class TunnelPool {
}
public void startup() {
synchronized (_inProgress) {
_inProgress.clear();
}
_alive = true;
_started = System.currentTimeMillis();
_lastRateUpdate = _started;
@ -91,6 +94,9 @@ public class TunnelPool {
_lastSelectionPeriod = 0;
_lastSelected = null;
_context.statManager().removeRateStat(_rateName);
synchronized (_inProgress) {
_inProgress.clear();
}
}
TunnelPoolManager getManager() { return _manager; }
@ -293,7 +299,9 @@ public class TunnelPool {
int remaining = 0;
LeaseSet ls = null;
synchronized (_tunnels) {
_tunnels.remove(info);
boolean removed = _tunnels.remove(info);
if (!removed)
return;
if (_settings.isInbound() && (_settings.getDestination() != null) )
ls = locked_buildNewLeaseSet();
remaining = _tunnels.size();
@ -334,12 +342,15 @@ public class TunnelPool {
}
}
/** This may be called multiple times from TestJob */
public void tunnelFailed(PooledTunnelCreatorConfig cfg) {
if (_log.shouldLog(Log.WARN))
_log.warn(toString() + ": Tunnel failed: " + cfg);
LeaseSet ls = null;
synchronized (_tunnels) {
_tunnels.remove(cfg);
boolean removed = _tunnels.remove(cfg);
if (!removed)
return;
if (_settings.isInbound() && (_settings.getDestination() != null) )
ls = locked_buildNewLeaseSet();
if (_lastSelected == cfg) {
@ -465,7 +476,7 @@ public class TunnelPool {
if (!_alive)
return null;
int wanted = _settings.getQuantity();
int wanted = Math.min(_settings.getQuantity(), LeaseSet.MAX_LEASES);
if (_tunnels.size() < wanted) {
if (_log.shouldLog(Log.WARN))
_log.warn(toString() + ": Not enough tunnels (" + _tunnels.size() + ", wanted " + wanted + ")");