forked from I2P_Developers/i2p.i2p
Transports:
- Increase threshold for idle timeout reduction from 33% to 60%. This was reduced from 75% to 33% in -10 and it caused significant tunnel build problems, for reasons that aren't entirely clear. - Don't change the SSU idle timeout quicker when firewalled. - log tweaks
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
2013-10-31 zzz
|
||||||
|
* i2psnark: Always verify file lengths at startup (ticket #1099)
|
||||||
|
* Transports: Increase threshold for idle timeout reduction
|
||||||
|
(partially back out change from -10)
|
||||||
|
|
||||||
2013-10-29 dg
|
2013-10-29 dg
|
||||||
* i2psnark: Start torrents by default (ticket #1072)
|
* i2psnark: Start torrents by default (ticket #1072)
|
||||||
|
|
||||||
|
@@ -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 = 17;
|
public final static long BUILD = 18;
|
||||||
|
|
||||||
/** for example "-test" */
|
/** for example "-test" */
|
||||||
public final static String EXTRA = "";
|
public final static String EXTRA = "";
|
||||||
|
@@ -211,7 +211,7 @@ class EventPumper implements Runnable {
|
|||||||
int failsafeInvalid = 0;
|
int failsafeInvalid = 0;
|
||||||
|
|
||||||
// Increase allowed idle time if we are well under allowed connections, otherwise decrease
|
// Increase allowed idle time if we are well under allowed connections, otherwise decrease
|
||||||
if (_transport.haveCapacity(33))
|
if (_transport.haveCapacity(60))
|
||||||
_expireIdleWriteTime = Math.min(_expireIdleWriteTime + 1000, MAX_EXPIRE_IDLE_TIME);
|
_expireIdleWriteTime = Math.min(_expireIdleWriteTime + 1000, MAX_EXPIRE_IDLE_TIME);
|
||||||
else
|
else
|
||||||
_expireIdleWriteTime = Math.max(_expireIdleWriteTime - 3000, MIN_EXPIRE_IDLE_TIME);
|
_expireIdleWriteTime = Math.max(_expireIdleWriteTime - 3000, MIN_EXPIRE_IDLE_TIME);
|
||||||
|
@@ -102,7 +102,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
*/
|
*/
|
||||||
private final Set<RemoteHostId> _dropList;
|
private final Set<RemoteHostId> _dropList;
|
||||||
|
|
||||||
private int _expireTimeout;
|
private volatile long _expireTimeout;
|
||||||
|
|
||||||
/** last report from a peer of our IP */
|
/** last report from a peer of our IP */
|
||||||
private Hash _lastFrom;
|
private Hash _lastFrom;
|
||||||
@@ -1217,11 +1217,11 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (entry.getType() == DatabaseEntry.KEY_TYPE_ROUTERINFO) {
|
if (entry.getType() == DatabaseEntry.KEY_TYPE_ROUTERINFO) {
|
||||||
if (_log.shouldLog(Log.INFO))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.info("Received an RI from the same net");
|
_log.debug("Received an RI from the same net");
|
||||||
} else {
|
} else {
|
||||||
if (_log.shouldLog(Log.INFO))
|
if (_log.shouldLog(Log.DEBUG))
|
||||||
_log.info("Received a leaseSet: " + dsm);
|
_log.debug("Received a leaseSet: " + dsm);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -2826,6 +2826,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
private final List<PeerState> _expireBuffer;
|
private final List<PeerState> _expireBuffer;
|
||||||
private volatile boolean _alive;
|
private volatile boolean _alive;
|
||||||
private int _runCount;
|
private int _runCount;
|
||||||
|
private boolean _lastLoopShort;
|
||||||
// we've seen firewalls change ports after 40 seconds
|
// we've seen firewalls change ports after 40 seconds
|
||||||
private static final long PING_FIREWALL_TIME = 30*1000;
|
private static final long PING_FIREWALL_TIME = 30*1000;
|
||||||
private static final long PING_FIREWALL_CUTOFF = PING_FIREWALL_TIME / 2;
|
private static final long PING_FIREWALL_CUTOFF = PING_FIREWALL_TIME / 2;
|
||||||
@@ -2833,6 +2834,8 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
private static final int SLICES = 4;
|
private static final int SLICES = 4;
|
||||||
private static final long SHORT_LOOP_TIME = PING_FIREWALL_CUTOFF / (SLICES + 1);
|
private static final long SHORT_LOOP_TIME = PING_FIREWALL_CUTOFF / (SLICES + 1);
|
||||||
private static final long LONG_LOOP_TIME = 25*1000;
|
private static final long LONG_LOOP_TIME = 25*1000;
|
||||||
|
private static final long EXPIRE_INCREMENT = 15*1000;
|
||||||
|
private static final long EXPIRE_DECREMENT = 45*1000;
|
||||||
|
|
||||||
public ExpirePeerEvent() {
|
public ExpirePeerEvent() {
|
||||||
super(_context.simpleTimer2());
|
super(_context.simpleTimer2());
|
||||||
@@ -2842,10 +2845,22 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
|
|
||||||
public void timeReached() {
|
public void timeReached() {
|
||||||
// Increase allowed idle time if we are well under allowed connections, otherwise decrease
|
// Increase allowed idle time if we are well under allowed connections, otherwise decrease
|
||||||
if (haveCapacity(33))
|
if (haveCapacity(60)) {
|
||||||
_expireTimeout = Math.min(_expireTimeout + 15*1000, EXPIRE_TIMEOUT);
|
long inc;
|
||||||
else
|
// don't adjust too quickly if we are looping fast
|
||||||
_expireTimeout = Math.max(_expireTimeout - 45*1000, MIN_EXPIRE_TIMEOUT);
|
if (_lastLoopShort)
|
||||||
|
inc = EXPIRE_INCREMENT * SHORT_LOOP_TIME / LONG_LOOP_TIME;
|
||||||
|
else
|
||||||
|
inc = EXPIRE_INCREMENT;
|
||||||
|
_expireTimeout = Math.min(_expireTimeout + inc, EXPIRE_TIMEOUT);
|
||||||
|
} else {
|
||||||
|
long dec;
|
||||||
|
if (_lastLoopShort)
|
||||||
|
dec = EXPIRE_DECREMENT * SHORT_LOOP_TIME / LONG_LOOP_TIME;
|
||||||
|
else
|
||||||
|
dec = EXPIRE_DECREMENT;
|
||||||
|
_expireTimeout = Math.max(_expireTimeout - dec, MIN_EXPIRE_TIMEOUT);
|
||||||
|
}
|
||||||
long now = _context.clock().now();
|
long now = _context.clock().now();
|
||||||
long shortInactivityCutoff = now - _expireTimeout;
|
long shortInactivityCutoff = now - _expireTimeout;
|
||||||
long longInactivityCutoff = now - EXPIRE_TIMEOUT;
|
long longInactivityCutoff = now - EXPIRE_TIMEOUT;
|
||||||
@@ -2855,6 +2870,7 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
int currentListenPort = getListenPort(false);
|
int currentListenPort = getListenPort(false);
|
||||||
boolean pingOneOnly = shouldPingFirewall && getExternalPort(false) == currentListenPort;
|
boolean pingOneOnly = shouldPingFirewall && getExternalPort(false) == currentListenPort;
|
||||||
boolean shortLoop = shouldPingFirewall;
|
boolean shortLoop = shouldPingFirewall;
|
||||||
|
_lastLoopShort = shortLoop;
|
||||||
_expireBuffer.clear();
|
_expireBuffer.clear();
|
||||||
_runCount++;
|
_runCount++;
|
||||||
|
|
||||||
@@ -2890,11 +2906,19 @@ public class UDPTransport extends TransportImpl implements TimedWeightedPriority
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (PeerState peer : _expireBuffer) {
|
if (!_expireBuffer.isEmpty()) {
|
||||||
sendDestroy(peer);
|
if (_log.shouldLog(Log.WARN))
|
||||||
dropPeer(peer, false, "idle too long");
|
_log.warn("Expiring " + _expireBuffer.size() + " peers");
|
||||||
|
for (PeerState peer : _expireBuffer) {
|
||||||
|
sendDestroy(peer);
|
||||||
|
dropPeer(peer, false, "idle too long");
|
||||||
|
// TODO sleep to limit burst like in destroyAll() ??
|
||||||
|
// but we are on the timer thread...
|
||||||
|
// hopefully this isn't too many at once
|
||||||
|
// ... or only send a max of x, then requeue
|
||||||
|
}
|
||||||
|
_expireBuffer.clear();
|
||||||
}
|
}
|
||||||
_expireBuffer.clear();
|
|
||||||
|
|
||||||
if (_alive)
|
if (_alive)
|
||||||
schedule(shortLoop ? SHORT_LOOP_TIME : LONG_LOOP_TIME);
|
schedule(shortLoop ? SHORT_LOOP_TIME : LONG_LOOP_TIME);
|
||||||
|
Reference in New Issue
Block a user