2005-12-16 jrandom

* Added some I2PSnark sanity checks, an OOMListener when running
      standalone, and a guard against keeping memory tied up indefinitely.
    * Sanity check on the watchdog (thanks zzz!)
    * Handle invalid HTTP requests in I2PTunnel a little better
This commit is contained in:
jrandom
2005-12-17 03:47:02 +00:00
committed by zzz
parent 7d234b1978
commit 1eb3ae5e1b
8 changed files with 98 additions and 8 deletions

View File

@@ -26,6 +26,7 @@ import java.util.*;
import net.i2p.util.I2PThread;
import net.i2p.util.Log;
import net.i2p.util.SimpleTimer;
class PeerConnectionOut implements Runnable
{
@@ -94,6 +95,8 @@ class PeerConnectionOut implements Runnable
// being send even if we get unchoked a little later.
// (Since we will resent them anyway in that case.)
// And remove piece messages if we are choking.
// this should get fixed for starvation
Iterator it = sendQueue.iterator();
while (m == null && it.hasNext())
{
@@ -177,10 +180,30 @@ class PeerConnectionOut implements Runnable
*/
private void addMessage(Message m)
{
SimpleTimer.getInstance().addEvent(new RemoveTooSlow(m), SEND_TIMEOUT);
synchronized(sendQueue)
{
sendQueue.add(m);
sendQueue.notify();
sendQueue.notifyAll();
}
}
/** remove messages not sent in 30s */
private static final int SEND_TIMEOUT = 30*1000;
private class RemoveTooSlow implements SimpleTimer.TimedEvent {
private Message _m;
public RemoveTooSlow(Message m) {
_m = m;
}
public void timeReached() {
boolean removed = false;
synchronized (sendQueue) {
removed = sendQueue.remove(_m);
sendQueue.notifyAll();
}
if (removed)
_log.info("Took too long to send " + _m + " to " + peer);
}
}
@@ -206,6 +229,7 @@ class PeerConnectionOut implements Runnable
removed = true;
}
}
sendQueue.notifyAll();
}
return removed;
}