Author: toad
Date: 2006-08-01 21:26:52 +0000 (Tue, 01 Aug 2006)
New Revision: 9842

Modified:
   trunk/freenet/src/freenet/node/Node.java
   trunk/freenet/src/freenet/node/Version.java
Log:
918: Delay start of ARK insertion.

Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java    2006-08-01 19:20:46 UTC (rev 
9841)
+++ trunk/freenet/src/freenet/node/Node.java    2006-08-01 21:26:52 UTC (rev 
9842)
@@ -160,7 +160,13 @@
                private ClientPutter inserter;
                private boolean shouldInsert;
                private Peer[] lastInsertedPeers;
+               private boolean canStart;

+               void start() {
+                       canStart = true;
+                       update();
+               }
+               
                public void update() {
                        Logger.minor(this, "update()");
                        if(!checkIPUpdated()) return;
@@ -209,6 +215,11 @@

                private void startInserter() {

+                       if(!canStart) {
+                               Logger.minor(this, "ARK inserter can't start 
yet");
+                               return;
+                       }
+                       
                        Logger.minor(this, "starting inserter");

                        SimpleFieldSet fs = exportPublicFieldSet();
@@ -986,7 +997,6 @@
                runningUIDs = new HashSet();
                dnsr = new DNSRequester(this);
                ps = new PacketSender(this);
-               nextPeerNodeStatusLogTime = System.currentTimeMillis() + 
(3*1000);
                // FIXME maybe these should persist? They need to be private 
though, so after the node/peers split. (bug 51).
                decrementAtMax = random.nextDouble() <= DECREMENT_AT_MAX_PROB;
                decrementAtMin = random.nextDouble() <= DECREMENT_AT_MIN_PROB;
@@ -1036,7 +1046,6 @@
                                        overrideIPAddress = null;
                                        lastIPAddress = null;
                                        redetectAddress();
-                                       shouldInsertARK();
                                        return;
                                }
                                FreenetInetAddress addr;
@@ -1086,7 +1095,6 @@
                                        throw new 
InvalidConfigValueException("Unknown host: "+e.getMessage());
                                }
                                redetectAddress();
-                               shouldInsertARK();
                        }

                });
@@ -1725,9 +1733,6 @@
                if(testnetHandler != null)
                        testnetHandler.start();

-               redetectAddress();
-               shouldInsertARK();
-               
                Thread t = new Thread(ipDetector, "IP address re-detector");
                t.setDaemon(true);
                t.start();
@@ -1819,6 +1824,15 @@
                }, "Startup completion thread");
                completer.setDaemon(true);
                completer.start();
+               
+               redetectAddress();
+               
+               // 60 second delay for inserting ARK to avoid reinserting more 
than necessary if we don't detect IP on startup.
+               ps.queueTimedJob(new FastRunnable() {
+                       public void run() {
+                               arkPutter.start();
+                       }
+               }, 60*1000);
        }

        private void shouldInsertARK() {
@@ -3369,7 +3383,7 @@
         */
        public void maybeLogPeerNodeStatusSummary(long now) {
          if(now > nextPeerNodeStatusLogTime) {
-               if((now - nextPeerNodeStatusLogTime) > (3*1000))
+               if((now - nextPeerNodeStatusLogTime) > (3*1000) && 
nextPeerNodeStatusLogTime > 0)
                  Logger.error(this,"maybeLogPeerNodeStatusSummary() not called 
for more than 3 seconds ("+(now - nextPeerNodeStatusLogTime)+").  PacketSender 
getting bogged down or something?");
                int numberOfConnected = 
getPeerNodeStatusSize(PEER_NODE_STATUS_CONNECTED);
                int numberOfRoutingBackedOff = 
getPeerNodeStatusSize(PEER_NODE_STATUS_ROUTING_BACKED_OFF);

Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-08-01 19:20:46 UTC (rev 
9841)
+++ trunk/freenet/src/freenet/node/Version.java 2006-08-01 21:26:52 UTC (rev 
9842)
@@ -18,7 +18,7 @@
        public static final String protocolVersion = "1.0";

        /** The build number of the current revision */
-       private static final int buildNumber = 917;
+       private static final int buildNumber = 918;

        /** Oldest build of Fred we will talk to */
        private static final int oldLastGoodBuild = 870;


Reply via email to