forked from I2P_Developers/i2p.i2p
new throttling code which rejects tunnel create requests, networkDb lookup requests, and even tells the I2NP components to stop reading from the network (it doesnt affect writing to the network)
the simple RouterThrottleImpl bases its decision entirely on how congested the jobQueue is - if there are jobs that have been waiting 5+ seconds, reject everything and stop reading from the network (each i2npMessageReader randomly waits .5-1s when throttled before rechecking it) minor adjustments in the stats published - removing a few useless ones and adding the router.throttleNetworkCause (which is the average ms lag in the jobQueue when an I2NP reader is throttled)
This commit is contained in:
@@ -114,6 +114,9 @@ public class I2NPMessageReader {
|
||||
public void run() {
|
||||
while (_stayAlive) {
|
||||
while (_doRun) {
|
||||
while (!_context.throttle().acceptNetworkMessage()) {
|
||||
try { Thread.sleep(500 + _context.random().nextInt(512)); } catch (InterruptedException ie) {}
|
||||
}
|
||||
// do read
|
||||
try {
|
||||
I2NPMessage msg = _handler.readMessage(_stream);
|
||||
|
||||
Reference in New Issue
Block a user