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

Modified Files:
        PeerHandler.java Version.java 
Log Message:
further tweaking of the needsConnection(true) algorithm. Should reduce connections 
opened and therefore CPU usage.


Index: PeerHandler.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/PeerHandler.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -w -r1.17 -r1.18
--- PeerHandler.java    14 Oct 2003 22:43:47 -0000      1.17
+++ PeerHandler.java    14 Oct 2003 23:06:18 -0000      1.18
@@ -151,6 +151,8 @@
                int closedCount = 0;
                int sendingCount = 0;
                int receivingCount = 0; // excludes those also sending
+               int notSendingCount = 0;
+               int notReceivingCount = 0;
                int freeCount = 0;
                synchronized(connectionHandlers) {
                        for(Iterator e = connectionHandlers.listIterator(0);
@@ -163,12 +165,15 @@
                                }
                                if(ch.sending()) {
                                        sendingCount++;
+                                       if(weak && !ch.receiving())
+                                               notReceivingCount++;
                                        continue;
-                               }
+                               } else
+                                       notSendingCount++;
                                if(weak && ch.receiving()) {
                                        receivingCount++;
                                        continue;
-                               }
+                               } else notReceivingCount++;
                                // If it is sending a trailer, it is not available
 //                             if(ch.isSendingPacket()) continue;
                                // But if it is sending only packets, it *IS* available
@@ -190,8 +195,8 @@
                                                        " closed "+closedCount+", 
sending "+
                                                        sendingCount+", free 
"+freeCount, Logger.DEBUG);
                if(weak) {
-                       if(freeCount + receivingCount < 2 // less than 2 free to send
-                          || freeCount < 1) // less than 1 free to receive
+                       if(notSendingCount < 2 // less than 2 free to send
+                          || notReceivingCount < 1) // less than 1 free to receive
                                return true;
                        else
                                return false;

Index: Version.java
===================================================================
RCS file: /cvsroot/freenet/freenet/src/freenet/Version.java,v
retrieving revision 1.436
retrieving revision 1.437
diff -u -w -r1.436 -r1.437
--- Version.java        14 Oct 2003 22:54:30 -0000      1.436
+++ Version.java        14 Oct 2003 23:06:18 -0000      1.437
@@ -18,7 +18,7 @@
     public static String protocolVersion = "1.46";
     
     /** The build number of the current revision */
-    public static final int buildNumber = 6243;
+    public static final int buildNumber = 6244;
     // 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