Update of /cvsroot/freenet/freenet/src/freenet
In directory sc8-pr-cvs1:/tmp/cvs-serv12146/src/freenet

Modified Files:
        ConnectionHandler.java OpenConnectionManager.java Version.java 
Log Message:
6194:
* Don't register CH in OCM if already finalized. This was causing minor problems (the 
Curus bug).
* In both FreenetConnectionRunner and OCM$ConnJob, check that the conn is open after 
configWSL, and kill the process if it isn't
* Enable selective logging in OCM
* Enable on the fly updating of logLevelDetail (untested)
* Logging


Index: ConnectionHandler.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/ConnectionHandler.java,v
retrieving revision 1.155
retrieving revision 1.156
diff -u -r1.155 -r1.156
--- ConnectionHandler.java      11 Sep 2003 15:32:41 -0000      1.155
+++ ConnectionHandler.java      12 Sep 2003 18:03:48 -0000      1.156
@@ -342,6 +342,7 @@
     }
        
        public void registerOCM() {
+               if(finalized.state()) return;
                if(logDEBUG) logDEBUG("registerOCM");
                if(!initRegisteredInOCM) {
                        if(logDEBUG) logDEBUG("registering OCM");

Index: OpenConnectionManager.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/OpenConnectionManager.java,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -r1.102 -r1.103
--- OpenConnectionManager.java  12 Sep 2003 04:40:31 -0000      1.102
+++ OpenConnectionManager.java  12 Sep 2003 18:03:49 -0000      1.103
@@ -54,6 +54,8 @@
     private final LRUQueue lru = new LRUQueue();
     private int maxConnections = -1;
     
+       private boolean logDEBUG = true;
+       
        private final boolean doHardConnectionLimit = true; // set true to enable 
special debugging for the Curus Bug (simultaneous connect attempts to the same node)!. 
FIXME: set false before release
     private boolean useOldStyle = false; //Keep track of what HTML mode the user last 
requested
     private int viewLevel = 0;
@@ -63,7 +65,8 @@
     public OpenConnectionManager(ThreadFactory tf, int maxConnections) {
         this.tf = tf;
         this.maxConnections = maxConnections;
-
+               
+               logDEBUG = Core.logger.shouldLog(Logger.DEBUG, this);
         chs = new MultiValueTable(50, 3);
         openConns = 0;
     }
@@ -112,7 +115,7 @@
                                                                        oldest = null;
                                                                // Or the oldest is an 
only-conn-to-this-RTNode and the 
                                                                // candidate is not... 
then use the candidate
-                                                                else 
if((!onlyRTNodeConn(candidate)) && onlyRTNodeConn(oldest))
+                                                               else 
if((!onlyRTNodeConn(candidate)) && onlyRTNodeConn(oldest))
                                                                        oldest = null;
                                                        }
                                                        if(oldest == null) {
@@ -145,10 +148,10 @@
     synchronized ConnectionHandler remove(ConnectionHandler ch) {
         //if (ch.peerIdentity() == null) return null;
         if (chs.removeElement(ch.peerIdentity(), ch)) {
-                       if(Core.logger.shouldLog(Core.logger.DEBUG))
+                       if(logDEBUG)
                                Core.logger.log(this, "Removed ConnectionHandler " + 
                                                                ch, new Exception 
("debug"), 
-                                                               Core.logger.DEBUG);
+                                                               Logger.DEBUG);
             Core.diagnostics.occurrenceCounting("liveConnections",
                                                                                       
         -1);
            
@@ -167,8 +170,8 @@
      * node identified.
      */
     public ConnectionHandler findFreeConnection(Identity id) {
-               boolean logDebug = Core.logger.shouldLog(Logger.DEBUG);
-               if (logDebug)
+               logDEBUG = Core.logger.shouldLog(Logger.DEBUG,this);
+               if (logDEBUG)
                Core.logger.log(this, "findFreeConnection("+id+")",
                                                new Exception("debug"), Logger.DEBUG);
                Enumeration e = chs.getAll(id); //moved this out here --zab
@@ -178,14 +181,14 @@
                        while (e.hasMoreElements()) {
                                ConnectionHandler res = (ConnectionHandler) 
e.nextElement();
                                if (!res.isOpen()) {
-                                       if(logDebug)
+                                       if(logDEBUG)
                                                Core.logger.log(this, "Skipped closed 
connection "+res,
                                                                                
Logger.MINOR);
                                        // It will be terminated eventually
                                        // Do not remove it from OCM because it will 
then be orphaned and take up a fd even though it is not available for sending.
                                } else if (!res.sending()) {
-                                       if (logDebug)
-                                       Core.logger.log(this, "Found "+res, 
Logger.MINOR);
+                                       if (logDEBUG)
+                                               Core.logger.log(this, "Found "+res, 
Logger.MINOR);
                                        // found one
                                        lru.push(res);
                                        // Mark this connection as cached
@@ -197,7 +200,7 @@
                                } else {
                                        if(!res.reallySending()){
                                                candidates.add(res);
-                                       } else if (logDebug) {
+                                       } else if (logDEBUG) {
                                                Core.logger.log(this, "Skipping: 
"+res+": sending",
                                                                                
Logger.MINOR);
                                        }
@@ -239,7 +242,7 @@
                                return best;
                        }
                }
-               if(logDebug)
+               if(logDEBUG)
                        Core.logger.log(this, "Couldn't find open connection for "+
                                                        id, Logger.DEBUG);
                return null;
@@ -257,7 +260,7 @@
         for (Enumeration e = chs.getAll(id) ; e.hasMoreElements() ; ) {
             res = (ConnectionHandler) e.nextElement();
             if (!res.isOpen()) {
-                               if(Core.logger.shouldLog(Logger.DEBUG))
+                               if(logDEBUG)
                                        Core.logger.log(this, "Skipped closed 
connection "+res,
                                                                        Logger.DEBUG);
                                // It will be terminated eventually
@@ -798,8 +801,8 @@
     private final void incHardConnectionLimit(Address addr)
         throws ConnectFailedException {
         int val = 0;
-               boolean logDebug = Core.logger.shouldLog(Logger.DEBUG);
-               if(logDebug)
+               logDEBUG = Core.logger.shouldLog(Logger.DEBUG,this);
+               if(logDEBUG)
                        Core.logger.log(this, "Increasing blocked connection count for 
"+addr.toString(),
                                                        Logger.DEBUG);
         synchronized(blockedConnections) {
@@ -809,7 +812,7 @@
                 val = count.intValue();
                 if (val >= MAXBLOCKEDCONNECTIONS) {
                     
-                                       if(logDebug)
+                                       if(logDEBUG)
                                                
Core.logger.log(OpenConnectionManager.this,
                                                                                " Too 
many blocked connection, aborting: " 
                                                                                + 
addr.toString() +
@@ -829,7 +832,7 @@
             blockedConnections.put(addr.toString(), new Integer(val + 1));
         
         }
-               if(logDebug) Core.logger.log(OpenConnectionManager.this,
+               if(logDEBUG) Core.logger.log(OpenConnectionManager.this,
                                                                         " blocked: " 
+ addr.toString() +
                                                                         " " + (val),
                                                                         
Logger.DEBUGGING);
@@ -837,8 +840,8 @@
     }
 
     private final void decHardConnectionLimit(Address addr) {
-               boolean logDebug = Core.logger.shouldLog(Logger.DEBUG);
-               if(logDebug)
+               logDEBUG = Core.logger.shouldLog(Logger.DEBUG,this);
+               if(logDEBUG)
                        Core.logger.log(this, "Decreasing blocked connection count for 
"+addr.toString(),
                                                        Logger.DEBUG);
         synchronized(blockedConnections) {
@@ -865,7 +868,8 @@
         private boolean done = false;
         private ConnectionHandler ch = null;
         private CommunicationException e = null;
-
+               
+               private boolean logDEBUG = false;
         private final Core core;
         private final Peer p;
                
@@ -888,7 +892,8 @@
                }
                
         public ConnectionJob(Core core, Peer p) {
-                       if(Core.logger.shouldLog(Logger.DEBUG))
+                       logDEBUG = Core.logger.shouldLog(Logger.DEBUG, this);
+                       if(logDEBUG)
                                Core.logger.log(this, "Creating ConnectionJob (core, 
"+p+"): "+
                                                                this, new 
Exception("debug"), Logger.DEBUG);
             this.core = core;
@@ -903,7 +908,6 @@
             boolean connected = false;
             int loops = 5;
             OutputStream crypt = null;
-                       boolean logDEBUG = core.logger.shouldLog(Logger.DEBUG);
             do {
                 try {
                     LinkManager linkManager = p.getLinkManager();
@@ -946,7 +950,7 @@
                             Core.outboundContacts.incTotal(countAddr);
                         }
                     }
-                                       if(Core.logger.shouldLog(Logger.MINOR))
+                                       if(Core.logger.shouldLog(Logger.MINOR,this))
                                                
Core.logger.log(OpenConnectionManager.this, 
                                                                                
"Established connection: " + c + "("+
                                                                                this + 
")", Logger.MINOR);
@@ -997,6 +1001,12 @@
                     //runCh = true;
                     //ch.start();
                                        ch.configWSL(tcpConnection.getWSL());
+                                       if(!ch.isOpen()) 
+                                               throw new 
ConnectFailedException(p.getAddress(),
+                                                                                      
                          p.getIdentity(),
+                                                                                      
                          "Conn died sending Identify",
+                                                                                      
                          true);
+                                       
                                        if(logDEBUG) Core.logger.log(this, "configged 
WSL for "+
                                                                                       
          ch+" ("+this+")", Logger.DEBUG);
                     if (!core.hasInterfaceFor(ch.transport())) {
@@ -1021,7 +1031,7 @@
                     
                 } catch (java.net.SocketException e) {
                                        //just log it
-                                       if(Core.logger.shouldLog(Logger.MINOR))
+                                       if(Core.logger.shouldLog(Logger.MINOR,this))
                                                Core.logger.log(this, "socket 
exception happened - "+
                                                                                
"probably NIOOS got closed before "+
                                                                                
"finishing: "+e,e,Logger.MINOR);
@@ -1091,7 +1101,7 @@
                     //}
                 } catch (NegotiationFailedException e) {
                     this.e = e;
-                                       if(core.logger.shouldLog(Logger.MINOR))
+                                       if(core.logger.shouldLog(Logger.MINOR,this))
                                                
core.logger.log(OpenConnectionManager.this,
                                                                                
"Negotiation failed with: "
                                                                                + 
p.getAddress() + " -- " + e+" ("+
@@ -1099,7 +1109,7 @@
                                        //e, Logger.MINOR);
                 } catch (AuthenticationFailedException e) {
                     this.e = e;
-                                       if(core.logger.shouldLog(Logger.MINOR))
+                                       if(core.logger.shouldLog(Logger.MINOR,this))
                                                
core.logger.log(OpenConnectionManager.this,
                                                                                
"Authentication failed with: "
                                                                                + 
p.getAddress() + " -- " + e+" ("+

Index: Version.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/Version.java,v
retrieving revision 1.386
retrieving revision 1.387
diff -u -r1.386 -r1.387
--- Version.java        12 Sep 2003 14:42:28 -0000      1.386
+++ Version.java        12 Sep 2003 18:03:49 -0000      1.387
@@ -18,7 +18,7 @@
     public static String protocolVersion = "1.46";
     
     /** The build number of the current revision */
-    public static final int buildNumber = 6193;
+    public static final int buildNumber = 6194;
     // 6028: may 3; ARK retrieval fix
 
     public static final int ignoreBuildsAfter = 6500;

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

Reply via email to