forked from I2P_Developers/i2p.i2p
SSU: Remove copy of peers in idle timeout checker
Just iterate through the main map. Log tweaks
This commit is contained in:
@@ -1773,7 +1773,6 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
if (oldPeer != null) {
|
||||
oldPeer.dropOutbound();
|
||||
_introManager.remove(oldPeer);
|
||||
_expireEvent.remove(oldPeer);
|
||||
RemoteHostId oldID = oldPeer.getRemoteHostId();
|
||||
if (!remoteId.equals(oldID)) {
|
||||
// leak fix, remove old address
|
||||
@@ -1784,7 +1783,6 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
if (oldPeer2 != oldPeer && oldPeer2 != null) {
|
||||
oldPeer2.dropOutbound();
|
||||
_introManager.remove(oldPeer2);
|
||||
_expireEvent.remove(oldPeer2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1805,7 +1803,6 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
oldEstablishedOn = oldPeer2.getKeyEstablishedTime();
|
||||
oldPeer2.dropOutbound();
|
||||
_introManager.remove(oldPeer2);
|
||||
_expireEvent.remove(oldPeer2);
|
||||
}
|
||||
|
||||
if (_log.shouldLog(Log.WARN) && !_mismatchLogged && _peersByIdent.size() != _peersByRemoteHost.size()) {
|
||||
@@ -1822,8 +1819,6 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
//if (SHOULD_FLOOD_PEERS)
|
||||
// _flooder.addPeer(peer);
|
||||
|
||||
_expireEvent.add(peer);
|
||||
|
||||
_introManager.add(peer);
|
||||
|
||||
if (oldEstablishedOn > 0)
|
||||
@@ -2006,7 +2001,6 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
|
||||
//if (SHOULD_FLOOD_PEERS)
|
||||
// _flooder.removePeer(peer);
|
||||
_expireEvent.remove(peer);
|
||||
|
||||
// deal with races to make sure we drop the peers fully
|
||||
if ( (altByIdent != null) && (peer != altByIdent) ) locked_dropPeer(altByIdent, shouldBanlist, "recurse");
|
||||
@@ -2163,7 +2157,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
void send(UDPPacket packet) {
|
||||
if (_pusher != null) {
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("Sending packet " + packet);
|
||||
_log.debug("Sending " + packet);
|
||||
_pusher.send(packet);
|
||||
} else {
|
||||
_log.error("No pusher", new Exception());
|
||||
@@ -2236,8 +2230,8 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
Hash to = toAddress.getIdentity().calculateHash();
|
||||
PeerState peer = getPeerState(to);
|
||||
if (peer != null) {
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("bidding on a message to an established peer: " + peer);
|
||||
//if (_log.shouldLog(Log.DEBUG))
|
||||
// _log.debug("bidding on a message to an established peer: " + peer);
|
||||
if (preferUDP())
|
||||
return _cachedBid[FAST_PREFERRED_BID];
|
||||
else
|
||||
@@ -2309,8 +2303,8 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
if (!allowConnection())
|
||||
return _cachedBid[TRANSIENT_FAIL_BID];
|
||||
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("bidding on a message to an unestablished peer: " + to);
|
||||
//if (_log.shouldLog(Log.DEBUG))
|
||||
// _log.debug("bidding on a message to an unestablished peer: " + to);
|
||||
|
||||
// Try to maintain at least 5 peers (30 for v6) so we can determine our IP address and
|
||||
// we have a selection to run peer tests with.
|
||||
@@ -2461,8 +2455,8 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
}
|
||||
}
|
||||
msg.timestamp("enqueueing for an already established peer");
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("Add to fragments for " + to);
|
||||
//if (_log.shouldLog(Log.DEBUG))
|
||||
// _log.debug("Add to fragments for " + to);
|
||||
|
||||
// See comments in DummyThrottle.java
|
||||
if (USE_PRIORITY)
|
||||
@@ -3446,8 +3440,8 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
continue; // Big RTT makes for a poor calculation
|
||||
skews.add(Long.valueOf(peer.getClockSkew() / 1000));
|
||||
}
|
||||
if (_log.shouldLog(Log.DEBUG))
|
||||
_log.debug("UDP transport returning " + skews.size() + " peer clock skews.");
|
||||
//if (_log.shouldLog(Log.DEBUG))
|
||||
// _log.debug("UDP transport returning " + skews.size() + " peer clock skews.");
|
||||
return skews;
|
||||
}
|
||||
|
||||
@@ -3541,8 +3535,6 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
}
|
||||
|
||||
private class ExpirePeerEvent extends SimpleTimer2.TimedEvent {
|
||||
// TODO why have separate Set, just use _peersByIdent.values()
|
||||
private final Set<PeerState> _expirePeers;
|
||||
private final List<PeerState> _expireBuffer;
|
||||
private volatile boolean _alive;
|
||||
private int _runCount;
|
||||
@@ -3561,7 +3553,6 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
|
||||
public ExpirePeerEvent() {
|
||||
super(_context.simpleTimer2());
|
||||
_expirePeers = new ConcurrentHashSet<PeerState>(128);
|
||||
_expireBuffer = new ArrayList<PeerState>();
|
||||
}
|
||||
|
||||
@@ -3599,8 +3590,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
_expireBuffer.clear();
|
||||
_runCount++;
|
||||
|
||||
for (Iterator<PeerState> iter = _expirePeers.iterator(); iter.hasNext(); ) {
|
||||
PeerState peer = iter.next();
|
||||
for (PeerState peer : _peersByIdent.values()) {
|
||||
long inactivityCutoff;
|
||||
// if we offered to introduce them, or we used them as introducer in last 2 hours
|
||||
if (peer.getWeRelayToThemAs() > 0 || peer.getIntroducerTime() > pingCutoff) {
|
||||
@@ -3616,7 +3606,6 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
}
|
||||
if ( (peer.getLastReceiveTime() < inactivityCutoff) && (peer.getLastSendTime() < inactivityCutoff) ) {
|
||||
_expireBuffer.add(peer);
|
||||
iter.remove();
|
||||
} else if (shouldPingFirewall &&
|
||||
((_runCount ^ peer.hashCode()) & (SLICES - 1)) == 0 &&
|
||||
peer.getLastSendOrPingTime() < pingFirewallCutoff &&
|
||||
@@ -3671,21 +3660,12 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
||||
schedule(loopTime);
|
||||
}
|
||||
|
||||
public void add(PeerState peer) {
|
||||
_expirePeers.add(peer);
|
||||
}
|
||||
|
||||
public void remove(PeerState peer) {
|
||||
_expirePeers.remove(peer);
|
||||
}
|
||||
|
||||
public void setIsAlive(boolean isAlive) {
|
||||
_alive = isAlive;
|
||||
if (isAlive) {
|
||||
reschedule(LONG_LOOP_TIME);
|
||||
} else {
|
||||
cancel();
|
||||
_expirePeers.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user