Changeset ad7dc66


Ignore:
Timestamp:
Nov 13, 2004 9:59:37 AM (16 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
3780d29
Parents:
258244f
git-author:
jrandom <jrandom> (11/13/04 09:59:37)
git-committer:
zzz <zzz@…> (11/13/04 09:59:37)
Message:

2004-11-13 jrandom

  • Added throttles on how many I2PTunnel client connections we open at once
  • Replaced some buffered streams in I2PTunnel with unbuffered streams, as the streaming library used should take care of any buffering.
  • Added a cache for some objects used in I2PTunnel, especially useful when there are many short lived connections.
  • Trimmed the SimpleTimer?'s processing a bit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • apps/i2ptunnel/java/src/net/i2p/i2ptunnel/I2PTunnelClientBase.java

    r258244f rad7dc66  
    5858    private String handlerName;
    5959
     60    private Object conLock = new Object();
     61    private int pendingConnections = 0;
     62   
    6063    //public I2PTunnelClientBase(int localPort, boolean ownDest,
    6164    //                 Logging l) {
     
    270273     */
    271274    protected void manageConnection(Socket s) {
    272         new ClientConnectionRunner(s, handlerName);
     275        boolean useBlocking = false;
     276        synchronized (conLock) {
     277            pendingConnections++;
     278            if (pendingConnections > 5)
     279                useBlocking = true;
     280        }
     281        if (useBlocking)
     282            clientConnectionRun(s);
     283        else
     284            new ClientConnectionRunner(s, handlerName);
    273285    }
    274286
     
    327339        public void run() {
    328340            clientConnectionRun(s);
     341            synchronized (conLock) {
     342                pendingConnections--;
     343            }
    329344        }
    330345    }
  • core/java/src/net/i2p/data/DataHelper.java

    r258244f rad7dc66  
    3535import java.util.zip.GZIPOutputStream;
    3636
     37import net.i2p.util.ByteCache;
    3738import net.i2p.util.OrderedProperties;
    3839
     
    738739        GZIPInputStream in = new GZIPInputStream(new ByteArrayInputStream(orig, offset, length), length);
    739740        ByteArrayOutputStream baos = new ByteArrayOutputStream(length * 2);
    740         byte buf[] = new byte[4 * 1024];
     741        ByteCache cache = ByteCache.getInstance(10, 4*1024);
     742        ByteArray ba = cache.acquire();
     743        byte buf[] = ba.getData(); // new byte[4 * 1024];
    741744        while (true) {
    742745            int read = in.read(buf);
     
    745748        }
    746749        byte rv[] = baos.toByteArray();
     750        cache.release(ba);
    747751        //if (_log.shouldLog(Log.DEBUG))
    748752        //    _log.debug("Decompression of " + orig.length + " into " + rv.length + " (or " + 100.0d
Note: See TracChangeset for help on using the changeset viewer.