Attached is diff against 6233.

It fixes bug in RSL, adds WSL diagnostics and removes code that tries to do the job of select.

diff -uwr freenet-unstable-latest/src/freenet/node/Main.java 
Myfreenet-unstable-latest/src/freenet/node/Main.java
--- freenet-unstable-latest/src/freenet/node/Main.java  2003-10-04 05:00:44.000000000 
+0100
+++ Myfreenet-unstable-latest/src/freenet/node/Main.java        2003-10-11 
11:13:46.000000000 +0100
@@ -1742,6 +1742,10 @@
                            "restart an existing session (key).",outConn);
        d.registerCounting("outboundOpenerConnections",d.MINUTE,
                                "The number of connections the Connection Opener 
starts",outConn);
+               d.registerCounting("writeSelectionScrewed", d.MINUTE,
+                                                  "The number of times NIO makes a 
zero byte "+
+                                                  "write after the JVM told it that 
the socket "+
+                                                  "was writable.", outConn);
 
         // inbound connections
 
diff -uwr freenet-unstable-latest/src/freenet/transport/AbstractSelectorLoop.java 
Myfreenet-unstable-latest/src/freenet/transport/AbstractSelectorLoop.java
--- freenet-unstable-latest/src/freenet/transport/AbstractSelectorLoop.java     
2003-10-09 17:00:58.000000000 +0100
+++ Myfreenet-unstable-latest/src/freenet/transport/AbstractSelectorLoop.java   
2003-10-11 15:32:10.000000000 +0100
@@ -337,11 +337,6 @@
        protected abstract boolean inspectChannels();
 
        /**
-        * this fixes the keyset.  We're missing reads
-        */
-       protected abstract void fixKeys();
-       
-       /**
         * last-mile remedy if the selector is totaly screwed.
         * this may very well have unforeseen consequences.
         * lets hope we never get to use this...
@@ -593,16 +588,6 @@
 //                                                     " connections ("+iter+")", 
Logger.DEBUG);
                        
                        currentSet=sel.selectedKeys(); 
-                       //currentSet.clear();
-                       //currentSet.addAll(sel.selectedKeys());
-                       
-                       if(logDebug)
-                               Core.logger.log(this, "Keys ready before fixKeys: "+
-                                                               currentlyActive+"/"+
-                                                               sel.keys().size(), 
Logger.DEBUG);
-                       
-                       fixKeys();
-                       //if (currentlyActive != currentSet.size()) 
Core.logger.log(this, "read the freaking book! "+ currentlyActive +" != "+ 
currentSet.size() ,Logger.ERROR);
                        currentlyActive = currentSet.size();
                        if(logDebug)
                                Core.logger.log(this, "Keys ready: 
"+currentlyActive+"/"+
diff -uwr freenet-unstable-latest/src/freenet/transport/ReadSelectorLoop.java 
Myfreenet-unstable-latest/src/freenet/transport/ReadSelectorLoop.java
--- freenet-unstable-latest/src/freenet/transport/ReadSelectorLoop.java 2003-09-26 
11:01:30.000000000 +0100
+++ Myfreenet-unstable-latest/src/freenet/transport/ReadSelectorLoop.java       
2003-10-11 12:11:18.000000000 +0100
@@ -144,35 +144,6 @@
        }
        
        /**
-        * we're missing reads.  This will try and fix it
-        */
-       protected final void fixKeys() {
-//             Set bigSet = sel.keys();
-//             //Core.logger.log(this,"size of bigSet "+bigSet.size()
-//             //                      + " size of smallSet " + 
currentSet.size(),Logger.NORMAL);
-//             Iterator i = bigSet.iterator();
-               
-//             while (i.hasNext()) {
-//                     SelectionKey current = (SelectionKey) i.next();
-                       
-//                     if (current.isValid() && current.isReadable())  {
-//                             // Don't check open, we need to see them as readable 
and
-//                             // then get the -1 read
-//                             if (logDebug)Core.logger.log(this, "fixKeys added "+
-//                                                                                    
  current.channel()+":"+
-//                                                                                    
  current.attachment(), 
-//                                                                                    
  Logger.DEBUG);
-//                             //Core.logger.log(this,"told you so!",Logger.ERROR);
-//                             currentSet.add(current);
-//                     }
-                       
-//             }
-               
-//             //Core.logger.log(this,"size of small set after fixing " + 
currentSet.size(),Logger.NORMAL);
-               //Core.logger.log(this,"size of small set after fixing " + 
f.size(),Logger.NORMAL);*/
-       }
-       
-       /**
         * a screwed channel is marked as available for read, but
         * a read() call on it returns -1.  Therefore...
         */
@@ -237,11 +208,11 @@
                                                if (logDebug)logBumper(bumper, sc, nc, 
2);
                                                try {
                                                        size = sc.read(bumper);
+                                                       i.remove();
                                                        if(size == 0) {
                                                                
Core.diagnostics.occurrenceCounting("readinessSelectionScrewed",1);
                                                                bumper.flip();
                                                                screwedSelections++;
-                                                               i.remove();
                                                                //noneWorking=false; 
//this isn't really a dud either
                                                                //and guess what 
happens - rsl starts sleeping 10 to 20 times a second
                                                                //which makes tons of 
system calls and the sys cpu usage stays up steady
diff -uwr freenet-unstable-latest/src/freenet/transport/WriteSelectorLoop.java 
Myfreenet-unstable-latest/src/freenet/transport/WriteSelectorLoop.java
--- freenet-unstable-latest/src/freenet/transport/WriteSelectorLoop.java        
2003-10-07 21:04:44.000000000 +0100
+++ Myfreenet-unstable-latest/src/freenet/transport/WriteSelectorLoop.java      
2003-10-11 15:38:55.000000000 +0100
@@ -295,21 +295,6 @@
         }
         
         /**
-         * recent long waits in CHOS.write prompted me to do this here as well
-         */
-        protected final void fixKeys() {
-               //this never adds anything
-               Iterator i = sel.keys().iterator();
-               while (i.hasNext()) {
-                       SelectionKey current = (SelectionKey) i.next();
-                       if (current.isValid() && current.isWritable() 
-                               && (!currentSet.contains(current)))
-                               Core.logger.log(this, "fixKeys added "+current,
-                                                               Logger.NORMAL);
-                       currentSet.add(current);
-               }
-        }
-        /**
          * overriden so that it will block when there is nothing
          * to send.  Otherwise the selector enters an endless loop
          */
@@ -590,8 +575,10 @@
                                try {
                                        sent = ((SocketChannel)curKey.channel()).
                                                write(currentJob.data);
-                                       //this should be here, not in finally
-                                       //if (sent==0) currentSet.remove(curKey);
+                                       currentSet.remove(curKey); // not needed but 
harmless
+                                       if (sent == 0) {
+                                               
Core.diagnostics.occurrenceCounting("writeSelectionScrewed",1);
+                                       }
                                } finally {
                                        if(currentJob.data.limit() != oldLimit)
                                                currentJob.data.limit(oldLimit);
@@ -719,9 +706,7 @@
                                                        e, e, Logger.ERROR);
                        e.printStackTrace();
                        success=false;
-               } /*finally {
-                       currentSet.clear();  //not needed anymore
-               }*/
+               }
                return success;
        }
        
_______________________________________________
Devl mailing list
[EMAIL PROTECTED]
http://dodo.freenetproject.org/cgi-bin/mailman/listinfo/devl

Reply via email to