Update of /cvsroot/freenet/freenet/src/freenet/support/io
In directory sc8-pr-cvs1:/tmp/cvs-serv25857/src/freenet/support/io

Modified Files:
      Tag: stable
        Bandwidth.java NIOInputStream.java NIOOutputStream.java 
        ThrottledInputStream.java 
Log Message:
5029: Merge from unstable after months of work. MASSIVE changes.
Highlights:
* Next Generation Routing, massive related changes
* Major changes to handling of messages and connections (PeerHandler and related 
changes)
* Even more non-blocking I/O
* Documentation improvements
* Lots of new diagnostics and config options
* Lots of bug fixes and performance tweaking
* Probably lots of new bugs too!


Index: Bandwidth.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/support/io/Bandwidth.java,v
retrieving revision 1.6.4.2.2.4
retrieving revision 1.6.4.2.2.5
diff -u -w -r1.6.4.2.2.4 -r1.6.4.2.2.5
--- Bandwidth.java      15 Aug 2003 03:05:56 -0000      1.6.4.2.2.4
+++ Bandwidth.java      28 Oct 2003 20:20:46 -0000      1.6.4.2.2.5
@@ -51,7 +51,7 @@
         if(averageBandwidth>0 && bandwidthPerTick<1)
             bandwidthPerTick = 1; //to ensure new connections stay throttled (public 
access)
         timeStarted=System.currentTimeMillis();
-        Core.logger.log(this.getClass(),"new 
Bandwidth("+bandwidth+","+averageBandwidth+","+type+")",Logger.NORMAL);
+        Core.logger.log(this.getClass(),"new 
Bandwidth("+bandwidth+","+averageBandwidth+","+type+")",Logger.MINOR);
     }
     
     public int currentBandwidthPerSecondAllowed() {
@@ -60,7 +60,7 @@
     
     public int maximumPacketLength() {
        //return 1492;
-       return Math.max(2048, origBandwidth/3);
+       return Math.max(1492, origBandwidth/3);
     }
     
     public int availableBandwidth() {
@@ -74,7 +74,7 @@
      */
     
     public void chargeBandwidth(int used) {
-       boolean logDEBUG = Core.logger.shouldLog(Logger.DEBUG);
+       boolean logDEBUG = Core.logger.shouldLog(Logger.DEBUG,this);
        if(logDEBUG)
            Core.logger.log(this, "chargeBandwidth("+used+")", 
                            new Exception("debug"), Core.logger.DEBUG);
@@ -111,7 +111,7 @@
      * will never block
      */
     public BandwidthToken chargeBandwidthAsync(int used) {
-       boolean logDEBUG = Core.logger.shouldLog(Logger.DEBUG);
+       boolean logDEBUG = Core.logger.shouldLog(Logger.DEBUG,this);
        int sleepTime = 0;
        if(logDEBUG)
            Core.logger.log(this, "chargeBandwidthAsync("+used+")", 
@@ -179,7 +179,7 @@
      */
     
     protected int getBandwidth(int desired) {
-       boolean logDEBUG = Core.logger.shouldLog(Logger.DEBUG);
+       boolean logDEBUG = Core.logger.shouldLog(Logger.DEBUG,this);
        if(logDEBUG)
            Core.logger.log(this, "getBandwidth("+desired+")", 
                            new Exception("debug"), Core.logger.DEBUG);
@@ -247,7 +247,7 @@
                 break;
             }
             if(millisToSleep > 0){
-               if(Core.logger.shouldLog(Logger.DEBUG) || millisToSleep>500)
+               if(Core.logger.shouldLog(Logger.DEBUG,this) || millisToSleep>500)
                    Core.logger.log(this, "Bandwidth waiting "+millisToSleep+
                                    ", total so far "+totalWaitMillis+"; available="+
                                    available+", desired="+desired,millisToSleep>500?

Index: NIOInputStream.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/support/io/NIOInputStream.java,v
retrieving revision 1.13.2.4
retrieving revision 1.13.2.5
diff -u -w -r1.13.2.4 -r1.13.2.5
--- NIOInputStream.java 12 Jul 2003 01:50:23 -0000      1.13.2.4
+++ NIOInputStream.java 28 Oct 2003 20:20:46 -0000      1.13.2.5
@@ -14,7 +14,7 @@
        private boolean disabledInSelector = false;
        private volatile boolean registered = false;
        private ByteBuffer accumulator;
-       private SelectableChannel chan;
+       private SocketChannel chan;
        private ReadSelectorLoop rsl;
        private NIOReader nextReader = null;
        private boolean logDEBUG;
@@ -26,14 +26,14 @@
        private static final Object profLock = new Object();
        public Object regLock, unregLock;
        
-       public NIOInputStream (ByteBuffer buf, SelectableChannel chan, 
+       public NIOInputStream (ByteBuffer buf, SocketChannel chan, 
                                                   tcpConnection conn) {
                this.accumulator = buf;
                this.chan = chan;
                regLock= new Object();
                unregLock = new Object();
                this.conn = conn;
-               logDEBUG = Core.logger.shouldLog(Logger.DEBUG);
+               logDEBUG = Core.logger.shouldLog(Logger.DEBUG,this);
                if(logDEBUG)
                        Core.logger.log(this, "Created "+this+" for "+conn+" on "+chan+
                                                        " with "+buf, Logger.DEBUG);
@@ -48,7 +48,7 @@
                return registered;
        }
        
-       public NIOInputStream(SelectableChannel chan, tcpConnection conn) {
+       public NIOInputStream(SocketChannel chan, tcpConnection conn) {
                this(ByteBuffer.allocateDirect(64*1024),
                        chan, conn);
                accumulator.limit(0).position(0);
@@ -68,7 +68,8 @@
        
        public void registered(){
                registered = true;
-               if(logDEBUG) Core.logger.log(this, "Registered "+this, Logger.DEBUG);
+               if(logDEBUG) Core.logger.log(this, "Registered "+this, 
+                                                                        new 
Exception("debug"), Logger.DEBUG);
                synchronized(regLock) {
                        regLock.notifyAll();
                }
@@ -85,11 +86,14 @@
                        if(!alreadyClosedLink) {
                                nextReader.configRSL(rsl);
                                rsl.register(chan, nextReader);
-                               rsl.scheduleMaintenance(nextReader);
+                               rsl.scheduleMaintenance(chan, nextReader);
                        } else {
                                nextReader.closed();
                        }
                        nextReader = null; // we won't get any traffic from RSL now
+               } else {
+                       if(logDEBUG)
+                               Core.logger.log(this, "nextReader == null", 
Logger.MINOR);
                }
                synchronized(unregLock) {
                        unregLock.notifyAll();
@@ -101,6 +105,8 @@
        }
        
        public int process(ByteBuffer b) {
+               if(logDEBUG) Core.logger.log(this, "process("+b+") ("+this+")",
+                                                                        Logger.DEBUG);
                if(b == null) return 1;
                else 
                        synchronized(accumulator) {
@@ -284,7 +290,7 @@
                                                if (alreadyClosedLink) return -1;
                                                accumulator.wait(5*60*1000);
                                                if (System.currentTimeMillis() - now 
>= 5*60*1000) {
-                                                       Core.logger.log(this, "waited 
more than 5 minutes in NIOIS.read() "+conn+":"+this+"- closing",Logger.MINOR);
+                                                       Core.logger.log(this, "waited 
more than 5 minutes in NIOIS.read() "+conn+":"+this+"- closing", new 
Exception("debug"), Logger.NORMAL);
                                                        close();
                                                        return -1;
                                                }

Index: NIOOutputStream.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/support/io/NIOOutputStream.java,v
retrieving revision 1.11.2.6
retrieving revision 1.11.2.7
diff -u -w -r1.11.2.6 -r1.11.2.7
--- NIOOutputStream.java        8 Aug 2003 01:40:25 -0000       1.11.2.6
+++ NIOOutputStream.java        28 Oct 2003 20:20:46 -0000      1.11.2.7
@@ -57,7 +57,10 @@
                //profiling
                //WARNING:remove before release
                instances++;
-               logDEBUG = Core.logger.shouldLog(Logger.DEBUG);
+               logDEBUG = Core.logger.shouldLog(Logger.DEBUG,this);
+               if(logDEBUG)
+                       Core.logger.log(this, "Created "+this+" for "+conn+" on "+chan,
+                                                       Logger.DEBUG);
        }
                
                public void configWSL(WriteSelectorLoop wsl){
@@ -87,7 +90,8 @@
                                        throw new SocketException("stream closed while 
writing");
                                }
                                if (System.currentTimeMillis() - now >= 5*60*1000) {
-                                       Core.logger.log(this,"NIOOS.write(byte[]) 
timed out. "+conn+" closing",Logger.ERROR);
+                               Core.logger.log(this,"NIOOS.write(byte[]) timed out. 
"+conn+
+                                                               ", 
closing",Logger.ERROR);
                                        close();
                                        throw new SocketException("stream closed while 
writing");
                                }

Index: ThrottledInputStream.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/support/io/ThrottledInputStream.java,v
retrieving revision 1.3.4.1
retrieving revision 1.3.4.1.2.1
diff -u -w -r1.3.4.1 -r1.3.4.1.2.1
--- ThrottledInputStream.java   13 Mar 2003 16:38:43 -0000      1.3.4.1
+++ ThrottledInputStream.java   28 Oct 2003 20:20:46 -0000      1.3.4.1.2.1
@@ -65,7 +65,7 @@
      */
         
     public int read() throws IOException {
-       boolean logDEBUG = Core.logger.shouldLog(Logger.DEBUG);
+       boolean logDEBUG = Core.logger.shouldLog(Logger.DEBUG,this);
        if(logDEBUG) Core.logger.log(this, "read()", Core.logger.DEBUG);
         int rv = super.read();
        if(logDEBUG) Core.logger.log(this, "done super.read()", Core.logger.DEBUG);
@@ -93,7 +93,7 @@
     public int read(byte[] data, int offset, int length)
         throws IOException
     {
-       boolean logDEBUG = Core.logger.shouldLog(Logger.DEBUG);
+       boolean logDEBUG = Core.logger.shouldLog(Logger.DEBUG,this);
        if(logDEBUG) Core.logger.log(this, "read(,,)", Core.logger.DEBUG);
         int rv = in.read(data, offset, length);
        if(logDEBUG) Core.logger.log(this, "super.read(,,) done", Core.logger.DEBUG);

_______________________________________________
cvs mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to