only recurse one time

This commit is contained in:
jrandom
2004-07-28 03:51:38 +00:00
committed by zzz
parent ffcc34c4f9
commit 5eaec4c841

View File

@ -30,6 +30,9 @@ class PoolingTunnelSelector {
} }
public List selectOutboundTunnelIds(TunnelPool pool, TunnelSelectionCriteria criteria) { public List selectOutboundTunnelIds(TunnelPool pool, TunnelSelectionCriteria criteria) {
return selectOutboundTunnelIds(pool, criteria, true);
}
public List selectOutboundTunnelIds(TunnelPool pool, TunnelSelectionCriteria criteria, boolean recurse) {
List tunnelIds = new ArrayList(criteria.getMinimumTunnelsRequired()); List tunnelIds = new ArrayList(criteria.getMinimumTunnelsRequired());
Set outIds = pool.getOutboundTunnels(); Set outIds = pool.getOutboundTunnels();
@ -61,8 +64,8 @@ class PoolingTunnelSelector {
pool.buildFakeTunnels(); pool.buildFakeTunnels();
rebuilt = true; rebuilt = true;
} }
if (rebuilt) if (rebuilt && recurse)
return selectOutboundTunnelIds(pool, criteria); return selectOutboundTunnelIds(pool, criteria, false);
List ordered = randomize(pool, tunnelIds); List ordered = randomize(pool, tunnelIds);
List rv = new ArrayList(criteria.getMinimumTunnelsRequired()); List rv = new ArrayList(criteria.getMinimumTunnelsRequired());
@ -76,6 +79,9 @@ class PoolingTunnelSelector {
} }
public List selectInboundTunnelIds(TunnelPool pool, TunnelSelectionCriteria criteria) { public List selectInboundTunnelIds(TunnelPool pool, TunnelSelectionCriteria criteria) {
return selectInboundTunnelIds(pool, criteria, true);
}
public List selectInboundTunnelIds(TunnelPool pool, TunnelSelectionCriteria criteria, boolean recurse) {
List tunnels = new ArrayList(criteria.getMinimumTunnelsRequired()); List tunnels = new ArrayList(criteria.getMinimumTunnelsRequired());
for (Iterator iter = pool.getFreeTunnels().iterator(); iter.hasNext(); ) { for (Iterator iter = pool.getFreeTunnels().iterator(); iter.hasNext(); ) {
@ -103,8 +109,8 @@ class PoolingTunnelSelector {
pool.buildFakeTunnels(); pool.buildFakeTunnels();
rebuilt = true; rebuilt = true;
} }
if (rebuilt) if (rebuilt && recurse)
return selectInboundTunnelIds(pool, criteria); return selectInboundTunnelIds(pool, criteria, false);
List ordered = randomize(pool, tunnels); List ordered = randomize(pool, tunnels);
List rv = new ArrayList(criteria.getMinimumTunnelsRequired()); List rv = new ArrayList(criteria.getMinimumTunnelsRequired());