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