2005-12-22 jrandom

* Cleaned up some buffer synchronization issues in I2PSnark that could
       cause blockage.
This commit is contained in:
jrandom
2005-12-22 10:04:12 +00:00
committed by zzz
parent 98277d3b64
commit 148dd99c86
8 changed files with 31 additions and 17 deletions

View File

@ -167,7 +167,7 @@ public class ConnectionAcceptor implements Runnable
if (true) {
in = new BufferedInputStream(in);
out = new BufferedOutputStream(out);
//out = new BufferedOutputStream(out);
}
if (_log.shouldLog(Log.DEBUG))
_log.debug("Handling socket from " + _socket.getPeerDestination().calculateHash().toBase64());

View File

@ -94,6 +94,10 @@ public class I2PSnarkUtil {
opts.setProperty("i2p.streaming.inactivityTimeout", "90000");
if (opts.getProperty("i2p.streaming.inactivityAction") == null)
opts.setProperty("i2p.streaming.inactivityAction", "1");
if (opts.getProperty("i2p.streaming.writeTimeout") == null)
opts.setProperty("i2p.streaming.writeTimeout", "90000");
if (opts.getProperty("i2p.streaming.readTimeout") == null)
opts.setProperty("i2p.streaming.readTimeout", "90000");
_manager = I2PSocketManagerFactory.createManager(_i2cpHost, _i2cpPort, opts);
}
return (_manager != null);

View File

@ -180,7 +180,10 @@ public class Peer implements Comparable
InputStream in = sock.getInputStream();
OutputStream out = sock.getOutputStream(); //new BufferedOutputStream(sock.getOutputStream());
if (true) {
out = new BufferedOutputStream(out);
// buffered output streams are internally synchronized, so we can't get through to the underlying
// I2PSocket's MessageOutputStream to close() it if we are blocking on a write(...). Oh, and the
// buffer is unnecessary anyway, as unbuffered access lets the streaming lib do the 'right thing'.
//out = new BufferedOutputStream(out);
in = new BufferedInputStream(sock.getInputStream());
}
//BufferedInputStream bis

View File

@ -208,8 +208,8 @@ class PeerConnectionOut implements Runnable
}
}
/** remove messages not sent in 2m */
private static final int SEND_TIMEOUT = 120*1000;
/** remove messages not sent in 3m */
private static final int SEND_TIMEOUT = 3*60*1000;
private class RemoveTooSlow implements SimpleTimer.TimedEvent {
private Message _m;
public RemoveTooSlow(Message m) {

View File

@ -160,22 +160,23 @@ public class PeerCoordinator implements PeerListener
public void halt()
{
halted = true;
List removed = new ArrayList();
synchronized(peers)
{
// Stop peer checker task.
timer.cancel();
// Stop peers.
Iterator it = peers.iterator();
while(it.hasNext())
{
Peer peer = (Peer)it.next();
peer.disconnect();
it.remove();
removePeerFromPieces(peer);
}
peerCount = peers.size();
removed.addAll(peers);
peers.clear();
peerCount = 0;
}
while (removed.size() > 0) {
Peer peer = (Peer)removed.remove(0);
peer.disconnect();
removePeerFromPieces(peer);
}
}
public void connected(Peer peer)

View File

@ -162,12 +162,14 @@ public class TrackerClient extends I2PThread
}
}
Random r = new Random();
while(!stop)
{
try
{
// Sleep some minutes...
Thread.sleep(SLEEP*60*1000);
int delay = SLEEP*60*1000 + r.nextInt(120*1000);
Thread.sleep(delay);
}
catch(InterruptedException interrupt)
{

View File

@ -1,4 +1,8 @@
$Id: history.txt,v 1.365 2005/12/19 21:01:37 jrandom Exp $
$Id: history.txt,v 1.366 2005/12/21 07:04:56 jrandom Exp $
2005-12-22 jrandom
* Cleaned up some buffer synchronization issues in I2PSnark that could
cause blockage.
2005-12-21 jrandom
* Adjusted I2PSnark's usage of the streaming lib (tweaking it for BT's

View File

@ -15,9 +15,9 @@ import net.i2p.CoreVersion;
*
*/
public class RouterVersion {
public final static String ID = "$Revision: 1.314 $ $Date: 2005/12/19 21:01:37 $";
public final static String ID = "$Revision: 1.315 $ $Date: 2005/12/21 07:04:55 $";
public final static String VERSION = "0.6.1.7";
public final static long BUILD = 8;
public final static long BUILD = 9;
public static void main(String args[]) {
System.out.println("I2P Router version: " + VERSION + "-" + BUILD);
System.out.println("Router ID: " + RouterVersion.ID);