Author: toad
Date: 2008-12-06 16:24:12 +0000 (Sat, 06 Dec 2008)
New Revision: 24099

Modified:
   trunk/freenet/src/freenet/clients/http/staticfiles/defaultbookmarks.dat
   trunk/freenet/src/freenet/node/FNPPacketMangler.java
   trunk/freenet/src/freenet/node/OpennetManager.java
   trunk/freenet/src/freenet/node/OpennetPeerNode.java
   trunk/freenet/src/freenet/node/PacketSender.java
   trunk/freenet/src/freenet/node/PeerNode.java
   trunk/freenet/src/freenet/node/RequestHandler.java
   trunk/freenet/test/freenet/support/io/MockInputStream.java
Log:
Revert back to 24088 for critical bugfix release.


Modified: 
trunk/freenet/src/freenet/clients/http/staticfiles/defaultbookmarks.dat
===================================================================
--- trunk/freenet/src/freenet/clients/http/staticfiles/defaultbookmarks.dat     
2008-12-06 16:20:20 UTC (rev 24098)
+++ trunk/freenet/src/freenet/clients/http/staticfiles/defaultbookmarks.dat     
2008-12-06 16:24:12 UTC (rev 24099)
@@ -7,26 +7,26 @@
 BookmarkCategory0.Content.Bookmark0.Name=The Ultimate FreeNet Index
 BookmarkCategory0.Content.Bookmark0.Description=A new one-page index with a 
menu including categories
 BookmarkCategory0.Content.Bookmark0.hasAnActivelink=true
[EMAIL 
PROTECTED],3dAcn4fX2LyxO6uCnWFTx-2HKZ89uruurcKwLSCxbZ4,AQACAAE/Ultimate-Freenet-Index/37/
[EMAIL 
PROTECTED],3dAcn4fX2LyxO6uCnWFTx-2HKZ89uruurcKwLSCxbZ4,AQACAAE/Ultimate-Freenet-Index/35/
 BookmarkCategory0.Content.Bookmark3.Name=Index des sites Français
 BookmarkCategory0.Content.Bookmark3.Description=A small French index with 
descriptions
 BookmarkCategory0.Content.Bookmark3.hasAnActivelink=true
[EMAIL 
PROTECTED],pOloLxnKWM~AL24iDMHOAvTvCqMlB-p2BO9zK96TOZA,AQACAAE/index_fr/77/
[EMAIL 
PROTECTED],pOloLxnKWM~AL24iDMHOAvTvCqMlB-p2BO9zK96TOZA,AQACAAE/index_fr/73/
 BookmarkCategory0.Content.Bookmark2.Name=Freenet Activelink Index (SLOW: 
graphical index, preloads all the sites, so takes *ages* to load)
 BookmarkCategory0.Content.Bookmark2.hasAnActivelink=true
 BookmarkCategory0.Content.Bookmark2.Description=A graphical freenet index 
(this will take a long time to load as it preloads the sites)
[EMAIL 
PROTECTED],xTFOV9ddCQQk6vQ6G~jfL6IzRUgmfMcZJ6nuySu~NUc,AQACAAE/activelink-index/95/
[EMAIL 
PROTECTED],xTFOV9ddCQQk6vQ6G~jfL6IzRUgmfMcZJ6nuySu~NUc,AQACAAE/activelink-index/93/
 BookmarkCategory0.Content.Bookmark1.Name=Freenet Activelink Index Text Version 
(a quick-loading non-graphical index site, no porn)
 BookmarkCategory0.Content.Bookmark1.hasAnActivelink=true
 BookmarkCategory0.Content.Bookmark1.Description=Text version of the Activelink 
Index
[EMAIL 
PROTECTED],xTFOV9ddCQQk6vQ6G~jfL6IzRUgmfMcZJ6nuySu~NUc,AQACAAE/activelink-index-text/56/
[EMAIL 
PROTECTED],xTFOV9ddCQQk6vQ6G~jfL6IzRUgmfMcZJ6nuySu~NUc,AQACAAE/activelink-index-text/54/
 BookmarkCategory1.Name=Freenet related software and documentation
 BookmarkCategory1.Content.BookmarkCategory=0
 BookmarkCategory1.Content.Bookmark=5
 BookmarkCategory1.Content.Bookmark0.Name=Freenet Message System
 BookmarkCategory1.Content.Bookmark0.Description=The official freesite of FMS, 
a spam resistant message board system for Freenet
 BookmarkCategory1.Content.Bookmark0.hasAnActivelink=true
[EMAIL PROTECTED],~BG-edFtdCC1cSH4O3BWdeIYa8Sw5DfyrSV-TKdO5ec,AQACAAE/fms/85/
[EMAIL PROTECTED],~BG-edFtdCC1cSH4O3BWdeIYa8Sw5DfyrSV-TKdO5ec,AQACAAE/fms/84/
 BookmarkCategory1.Content.Bookmark1.Name=Freemail
 BookmarkCategory1.Content.Bookmark1.Description=The official site for Freemail 
- email over Freenet
 BookmarkCategory1.Content.Bookmark1.hasAnActivelink=true
@@ -39,7 +39,7 @@
 BookmarkCategory1.Content.Bookmark3.Name=Freesite HOWTO
 BookmarkCategory1.Content.Bookmark3.Description=A more detailed explanation of 
publishing freesites
 BookmarkCategory1.Content.Bookmark3.hasAnActivelink=true
[EMAIL PROTECTED],9T20t3xoG-dQfMO94LGOl9AxRTkaz~TykFY-voqaTQI,AQACAAE/FAFS/44/
[EMAIL PROTECTED],9T20t3xoG-dQfMO94LGOl9AxRTkaz~TykFY-voqaTQI,AQACAAE/FAFS/4/
 BookmarkCategory1.Content.Bookmark4.hasAnActivelink=true
 BookmarkCategory1.Content.Bookmark4.Name=The Freenet Applications Freesite
 BookmarkCategory1.Content.Bookmark4.Description=Various links to Freenet 
applications, and instructions for using them

Modified: trunk/freenet/src/freenet/node/FNPPacketMangler.java
===================================================================
--- trunk/freenet/src/freenet/node/FNPPacketMangler.java        2008-12-06 
16:20:20 UTC (rev 24098)
+++ trunk/freenet/src/freenet/node/FNPPacketMangler.java        2008-12-06 
16:24:12 UTC (rev 24099)
@@ -303,7 +303,7 @@
                OpennetManager opennet = node.getOpennet();
                if(opennet != null) {
                        // Try old opennet connections.
-                       if(opennet.wantPeer(null, false, true, true)) {
+                       if(opennet.wantPeer(null, false, true)) {
                                // We want a peer.
                                // Try old connections.
                                PeerNode[] oldPeers = opennet.getOldPeers();
@@ -551,7 +551,7 @@
                        Logger.error(this, "Decrypted auth packet but invalid 
version: "+version);
                        return;
                }
-               if(!(negType == 2 || negType == 3 || negType == 4)) {
+               if(!(negType == 2 || negType == 3)) {
                        Logger.error(this, "Unknown neg type: "+negType);
                        return;
                }
@@ -1201,7 +1201,7 @@
                                Logger.normal(this, "Dumping incoming 
old-opennet peer as opennet just turned off: "+pn+".");
                                return;
                        }
-                       if(!opennet.wantPeer(pn, true, false, true)) {
+                       if(!opennet.wantPeer(pn, true, false)) {
                                Logger.normal(this, "No longer want peer "+pn+" 
- dumping it after connecting");
                                dontWant = true;
                        }
@@ -1417,7 +1417,7 @@
                                Logger.normal(this, "Dumping incoming 
old-opennet peer as opennet just turned off: "+pn+".");
                                return true;
                        }
-                       if(!opennet.wantPeer(pn, true, false, true)) {
+                       if(!opennet.wantPeer(pn, true, false)) {
                                Logger.normal(this, "No longer want peer "+pn+" 
- dumping it after connecting");
                                dontWant = true;
                        }

Modified: trunk/freenet/src/freenet/node/OpennetManager.java
===================================================================
--- trunk/freenet/src/freenet/node/OpennetManager.java  2008-12-06 16:20:20 UTC 
(rev 24098)
+++ trunk/freenet/src/freenet/node/OpennetManager.java  2008-12-06 16:24:12 UTC 
(rev 24099)
@@ -58,7 +58,7 @@
         * if we have no other option. */
        private final LRUQueue oldPeers;
        /** Maximum number of old peers */
-       static final int MAX_OLD_PEERS = 25;
+       static final int MAX_OLD_PEERS = 50;
        /** Time at which last dropped a peer */
        private long timeLastDropped;
        /** Number of successful CHK requests since last added a node */
@@ -246,7 +246,7 @@
                        if(logMINOR) Logger.minor(this, "Not adding 
"+pn.userToString()+" to opennet list as already there");
                        return null;
                }
-               if(wantPeer(pn, true, false, false)) return pn;
+               if(wantPeer(pn, true, false)) return pn;
                else return null;
                // Start at bottom. Node must prove itself.
        }
@@ -265,10 +265,6 @@
                dropExcessPeers();
        }
        
-       private long timeLastAddedOldOpennetPeer = -1;
-       
-       private static final int OLD_OPENNET_PEER_INTERVAL = 30*1000;
-       
        /**
         * Trim the peers list and possibly add a new node. Note that if we are 
not adding a new node,
         * we will only return true every MIN_TIME_BETWEEN_OFFERS, to prevent 
problems caused by many
@@ -277,19 +273,11 @@
         * @param addAtLRU If there is a node to add, add it at the bottom 
rather than the top. Normally
         * we set this on new path folded nodes so that they will be replaced 
if during the trial period,
         * plus the time it takes to get a new path folding offer, they don't 
have a successful request.
-        * @param justChecking If true, we want to know whether there is space 
for a node to be added
-        * RIGHT NOW. If false, the normal behaviour applies: if nodeToAddNow 
is passed in, we decide
-        * whether to add that node, if it's null, we decide whether to send an 
offer subject to the
-        * inter-offer time.
-        * @param oldOpennetPeer If true, we are trying to add an 
old-opennet-peer which has reconnected.
-        * There is a throttle, we accept no more than one old-opennet-peer 
every 30 seconds. On receiving
-        * a packet, we call once to decide whether to try to parse it against 
the old-opennet-peers, and
-        * then again to decide whether it is worth keeping; in the latter case 
if we decide not, the
-        * old-opennet-peer will be told to disconnect and go away, but 
normally we don't reach that point
-        * because of the first check.
+        * @param justChecking If true, and nodeToAddNow == null, we don't 
actually send an offer, we
+        * just want to know if there is space for a node.
         * @return True if the node was added / should be added.
         */
-       public boolean wantPeer(PeerNode nodeToAddNow, boolean addAtLRU, 
boolean justChecking, boolean oldOpennetPeer) {
+       public boolean wantPeer(PeerNode nodeToAddNow, boolean addAtLRU, 
boolean justChecking) {
                boolean notMany = false;
                boolean noDisconnect;
                synchronized(this) {
@@ -313,9 +301,6 @@
                                if(nodeToAddNow != null || !justChecking)
                                        timeLastOffered = 
System.currentTimeMillis();
                                notMany = true;
-                               // Don't check timeLastAddedOldOpennetPeer, 
since we want it anyway. But do update it.
-                               if(oldOpennetPeer)
-                                       timeLastAddedOldOpennetPeer = 
System.currentTimeMillis();
                        }
                        noDisconnect = successCount < 
MIN_SUCCESS_BETWEEN_DROP_CONNS;
                }
@@ -351,12 +336,8 @@
                                peersLRU.remove(toDrop);
                                dropList.add(toDrop);
                        }
-                       long now = System.currentTimeMillis();
-                       if(canAdd && oldOpennetPeer) {
-                               if(timeLastAddedOldOpennetPeer > 0 && now - 
timeLastAddedOldOpennetPeer > OLD_OPENNET_PEER_INTERVAL)
-                                       canAdd = false;
-                       }
-                       if(canAdd && !justChecking) {
+                       if(canAdd) {
+                               long now = System.currentTimeMillis();
                                if(nodeToAddNow != null) {
                                        successCount = 0;
                                        if(addAtLRU)
@@ -367,8 +348,6 @@
                                        oldPeers.remove(nodeToAddNow);
                                        if(!dropList.isEmpty())
                                                timeLastDropped = now;
-                                       if(oldOpennetPeer)
-                                               timeLastAddedOldOpennetPeer = 
now;
                                } else {
                                        if(now - timeLastOffered <= 
MIN_TIME_BETWEEN_OFFERS && !hasDisconnected) {
                                                if(logMINOR)
@@ -424,12 +403,11 @@
                        for(int i=0;i<peers.length;i++) {
                                OpennetPeerNode pn = peers[i];
                                if(pn == null) continue;
-                               if(!pn.isDroppable(false)) continue;
+                               if(!pn.isDroppable()) continue;
                                // LOCKING: Always take the OpennetManager lock 
first
                                if(!pn.isConnected()) {
                                        if(Logger.shouldLog(Logger.MINOR, this))
                                                Logger.minor(this, "Possibly 
dropping opennet peer "+pn+" as is disconnected");
-                                       pn.setWasDropped();
                                        return pn;
                                }
                        }
@@ -439,11 +417,10 @@
                        for(int i=0;i<peers.length;i++) {
                                OpennetPeerNode pn = peers[i];
                                if(pn == null) continue;
-                               if(!pn.isDroppable(false)) continue;
+                               if(!pn.isDroppable()) continue;
                                if(Logger.shouldLog(Logger.MINOR, this))
                                        Logger.minor(this, "Possibly dropping 
opennet peer "+pn+" "+
                                                        
(System.currentTimeMillis() - timeLastDropped)+" ms since last dropped peer");
-                               pn.setWasDropped();
                                return pn;
                        }
                }
@@ -462,18 +439,16 @@
                                // Re-add it: nasty race condition when we have 
few peers
                        }
                }
-               if(!wantPeer(pn, false, false, false)) // Start at top as it 
just succeeded
+               if(!wantPeer(pn, false, false)) // Start at top as it just 
succeeded
                        node.peers.disconnect(pn, true, false);
        }
 
        public void onRemove(OpennetPeerNode pn) {
                synchronized (this) {
                        peersLRU.remove(pn);
-                       if(pn.isDroppable(true) && !pn.grabWasDropped()) {
-                               oldPeers.push(pn);
-                               while (oldPeers.size() > MAX_OLD_PEERS)
-                                       oldPeers.pop();
-                       }
+                       oldPeers.push(pn);
+                       while (oldPeers.size() > MAX_OLD_PEERS)
+                               oldPeers.pop();
                }
        }
 

Modified: trunk/freenet/src/freenet/node/OpennetPeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/OpennetPeerNode.java 2008-12-06 16:20:20 UTC 
(rev 24098)
+++ trunk/freenet/src/freenet/node/OpennetPeerNode.java 2008-12-06 16:24:12 UTC 
(rev 24099)
@@ -35,14 +35,13 @@
                return true;
        }
        
-       public boolean isDroppable(boolean ignoreDisconnect) {
+       public boolean isDroppable() {
                long now = System.currentTimeMillis();
                if(now - getPeerAddedTime() < OpennetManager.DROP_MIN_AGE)
                        return false; // New node
                if(now - node.usm.getStartedTime() < 
OpennetManager.DROP_STARTUP_DELAY)
                        return false; // Give them time to connect after we 
startup
                int status = getPeerNodeStatus();
-               if(!ignoreDisconnect) {
                synchronized(this) {
                        if((status == 
PeerManager.PEER_NODE_STATUS_DISCONNECTED) && (!super.neverConnected()) && 
                                        now - timeLastDisconnect < 
OpennetManager.DROP_DISCONNECT_DELAY &&
@@ -51,7 +50,6 @@
                                return false;
                        }
                }
-               }
                return true;
        }
        
@@ -121,20 +119,4 @@
                
opennet.crypto.socket.getAddressTracker().setPresumedGuiltyAt(System.currentTimeMillis()+60*60*1000);
        }
        
-       private boolean wasDropped;
-
-       synchronized void setWasDropped() {
-               wasDropped = true;
-       }
-       
-       synchronized boolean wasDropped() {
-               return wasDropped;
-       }
-       
-       synchronized boolean grabWasDropped() {
-               boolean ret = wasDropped;
-               wasDropped = false;
-               return ret;
-       }
-       
 }

Modified: trunk/freenet/src/freenet/node/PacketSender.java
===================================================================
--- trunk/freenet/src/freenet/node/PacketSender.java    2008-12-06 16:20:20 UTC 
(rev 24098)
+++ trunk/freenet/src/freenet/node/PacketSender.java    2008-12-06 16:24:12 UTC 
(rev 24099)
@@ -306,31 +306,28 @@
                }
                brokeAt = newBrokeAt;
 
-               /* Attempt to connect to old-opennet-peers.
-                * Constantly send handshake packets, in order to get through a 
NAT.
-                * Most JFK(1)'s are less than 300 bytes. 25*300/15 = avg 
500B/sec bandwidth cost.
-                * Well worth it to allow us to reconnect more quickly. */
-               
+               // Consider sending connect requests to our opennet old-peers.
+               // No point if they are NATed, of course... but we don't know 
whether they are.
                OpennetManager om = node.getOpennet();
                if(om != null) {
-                       PeerNode[] peers = om.getOldPeers();
-                       
-                       for(PeerNode pn : peers) {
-                               if(pn.isConnected()) continue; // Race 
condition??
-                               if(pn.noContactDetails()) {
-                                       pn.startARKFetcher();
-                                       continue;
-                               }
-                               if(pn.shouldSendHandshake()) {
-                                       // Send handshake if necessary
-                                       long beforeHandshakeTime = 
System.currentTimeMillis();
+                       int connCount = node.peers.quickCountConnectedPeers();
+                       int minDelay = connCount == 0 ? 
MIN_OLD_OPENNET_CONNECT_DELAY_NO_CONNS : MIN_OLD_OPENNET_CONNECT_DELAY;
+                       if(logDEBUG)
+                               Logger.debug(this, "Conns " + connCount + " 
minDelay " + minDelay + " old opennet peers " + om.countOldOpennetPeers() + " 
last sent " + (now - timeLastSentOldOpennetConnectAttempt) + " startup " + (now 
- node.startupTime));
+                       if(now - timeLastSentOldOpennetConnectAttempt > 
minDelay &&
+                               connCount <= 
MIN_CONNECTIONS_TRY_OLD_OPENNET_PEERS &&
+                               om.countOldOpennetPeers() > 0 &&
+                               now - node.startupTime > 
OpennetManager.DROP_STARTUP_DELAY) {
+                               PeerNode pn = om.randomOldOpennetNode();
+                               if(pn != null) {
+                                       if(logMINOR)
+                                               Logger.minor(this, "Sending 
old-opennet connect attempt to " + pn);
                                        
pn.getOutgoingMangler().sendHandshake(pn);
-                                       long afterHandshakeTime = 
System.currentTimeMillis();
-                                       if((afterHandshakeTime - 
beforeHandshakeTime) > (2 * 1000))
-                                               Logger.error(this, 
"afterHandshakeTime is more than 2 seconds past beforeHandshakeTime (" + 
(afterHandshakeTime - beforeHandshakeTime) + ") in PacketSender working with " 
+ pn.userToString());
+                                       timeLastSentOldOpennetConnectAttempt = 
now;
+                                       if(pn.noContactDetails() && 
node.getPeerNodes().length > 0 && connCount > 0 && node.random.nextBoolean())
+                                               pn.startARKFetcher();
                                }
                        }
-                       
                }
 
                if(now - lastClearedOldSwapChains > 10000) {

Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java        2008-12-06 16:20:20 UTC 
(rev 24098)
+++ trunk/freenet/src/freenet/node/PeerNode.java        2008-12-06 16:24:12 UTC 
(rev 24099)
@@ -1905,6 +1905,7 @@
                        } else if(bootIDChanged && logMINOR)
                                Logger.minor(this, "Changed boot ID from " + 
bootID + " to " + thisBootID + " for " + getPeer());
                        this.bootID = thisBootID;
+                       boolean newPacketTracker = false;
                        if(currentTracker != null && 
currentTracker.packets.trackerID == trackerID && 
!currentTracker.packets.isDeprecated()) {
                                if(isJFK4 && !jfk4SameAsOld)
                                        Logger.error(this, "In JFK(4), found 
tracker ID "+trackerID+" but other side says is new! for "+this);
@@ -1922,6 +1923,7 @@
                        } else if(trackerID == -1) {
                                // Create a new tracker unconditionally
                                packets = new PacketTracker(this);
+                               newPacketTracker = true;
                                if(logMINOR) Logger.minor(this, "Creating new 
PacketTracker as instructed for "+this);
                        } else if(trackerID == -2 && !bootIDChanged) {
                                // Reuse if not deprecated and not boot ID 
changed
@@ -1933,6 +1935,7 @@
                                        if(logMINOR) Logger.minor(this, 
"Re-using packet tracker (not given an ID): "+packets.trackerID+" on "+this+" 
from prev "+previousTracker);
                                } else {
                                        packets = new PacketTracker(this);
+                                       newPacketTracker = true;
                                        if(logMINOR) Logger.minor(this, "Cannot 
reuse trackers (not given an ID) on "+this);
                                }
                        } else {
@@ -1943,9 +1946,11 @@
                                        packets = new PacketTracker(this, 
trackerID);
                                } else
                                        packets = new PacketTracker(this);
+                               newPacketTracker = true;
                                if(logMINOR) Logger.minor(this, "Creating new 
tracker (last resort) on "+this);
                        }
                        if(bootIDChanged) {
+                               newPacketTracker = true;
                                oldPrev = previousTracker;
                                oldCur = currentTracker;
                                previousTracker = null;
@@ -1959,7 +1964,7 @@
                                // else it's a rekey
                        }
                        newTracker = new KeyTracker(this, packets, encCipher, 
encKey);
-                       if(logMINOR) Logger.minor(this, "New key tracker in 
completedHandshake: "+newTracker+" for "+shortToString()+" neg type "+negType);
+                       if(logMINOR) Logger.minor(this, "New key tracker in 
completedHandshake: "+newTracker+" for "+shortToString()+" neg type "+negType+" 
new packet tracker: "+newPacketTracker);
                        if(unverified) {
                                if(unverifiedTracker != null) {
                                        // Keep the old unverified tracker if 
possible.

Modified: trunk/freenet/src/freenet/node/RequestHandler.java
===================================================================
--- trunk/freenet/src/freenet/node/RequestHandler.java  2008-12-06 16:20:20 UTC 
(rev 24098)
+++ trunk/freenet/src/freenet/node/RequestHandler.java  2008-12-06 16:24:12 UTC 
(rev 24099)
@@ -558,7 +558,7 @@
        private boolean finishOpennetNoRelayInner(OpennetManager om) {
                if(logMINOR)
                        Logger.minor(this, "Finishing opennet: sending own 
reference");
-               if(!om.wantPeer(null, false, false, false))
+               if(!om.wantPeer(null, false, false))
                        return false; // Don't want a reference
 
                try {


Property changes on: trunk/freenet/test/freenet/support/io/MockInputStream.java
___________________________________________________________________
Deleted: svn:mergeinfo
   - 

_______________________________________________
cvs mailing list
[email protected]
http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs

Reply via email to