Author: toad
Date: 2006-07-08 19:30:00 +0000 (Sat, 08 Jul 2006)
New Revision: 9510

Modified:
   trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
   trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
   trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java
   trunk/freenet/src/freenet/node/CHKInsertSender.java
   trunk/freenet/src/freenet/node/Version.java
   trunk/freenet/src/freenet/support/TokenBucket.java
Log:
866: Fix an inserts bug. Mandatory at midnight GMT.

Modified: trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
===================================================================
--- trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java  
2006-07-08 14:10:46 UTC (rev 9509)
+++ trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java  
2006-07-08 19:30:00 UTC (rev 9510)
@@ -128,7 +128,7 @@
                                        return;
                                }
                                if(block != null) {
-                                       Logger.minor(this, "Can fulfill 
immediately from store");
+                                       Logger.minor(this, "Can fulfill "+req+" 
immediately from store");
                                        getter.onSuccess(block, true);
                                        return;
                                }
@@ -141,6 +141,7 @@
        }

        private synchronized void innerRegister(SendableRequest req) {
+               Logger.minor(this, "Still registering "+req+" at prio 
"+req.getPriorityClass()+" retry "+req.getRetryCount());
                addToGrabArray(req.getPriorityClass(), req.getRetryCount(), 
req.getClient(), req.getClientRequest(), req);
                HashSet v = (HashSet) 
allRequestsByClientRequest.get(req.getClientRequest());
                if(v == null) {
@@ -193,8 +194,10 @@
                while(iteration++ < RequestStarter.NUMBER_OF_PRIORITY_CLASSES + 
1){
                        priority = fuzz<0 ? 
tweakedPrioritySelector[random.nextInt(tweakedPrioritySelector.length)] : 
prioritySelector[Math.abs(fuzz % prioritySelector.length)];
                        result = priorities[priority];
-                       if(result != null && !result.isEmpty()) 
+                       if(result != null && !result.isEmpty()) {
+                               Logger.minor(this, "Found "+priority);
                                return result;
+                       }

                        Logger.minor(this, "Priority "+priority+" is null (fuzz 
= "+fuzz+")");
                        fuzz++;

Modified: trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java
===================================================================
--- trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java     
2006-07-08 14:10:46 UTC (rev 9509)
+++ trunk/freenet/src/freenet/clients/http/SimpleToadletServer.java     
2006-07-08 19:30:00 UTC (rev 9510)
@@ -326,7 +326,7 @@
                }

                void start() {
-                       Thread t = new Thread(this, 
"SimpleToadletServer$SocketHandler");
+                       Thread t = new Thread(this, toString());
                        t.setDaemon(true);
                        t.start();
                }

Modified: trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java
===================================================================
--- trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java     2006-07-08 
14:10:46 UTC (rev 9509)
+++ trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java     2006-07-08 
19:30:00 UTC (rev 9510)
@@ -75,7 +75,7 @@
                        // Will throw on running
                }
                throttle = PacketThrottle.getThrottle(_destination.getPeer(), 
_prb._packetSize);
-               _senderThread = new Thread("_senderThread for "+_uid) {
+               _senderThread = new Thread("_senderThread for "+_uid+ " to 
"+_destination.getPeer()) {

                        public void run() {
                                int sentSinceLastPing = 0;

Modified: trunk/freenet/src/freenet/node/CHKInsertSender.java
===================================================================
--- trunk/freenet/src/freenet/node/CHKInsertSender.java 2006-07-08 14:10:46 UTC 
(rev 9509)
+++ trunk/freenet/src/freenet/node/CHKInsertSender.java 2006-07-08 19:30:00 UTC 
(rev 9510)
@@ -541,6 +541,7 @@
                                }
                        }
                } else {
+                       Logger.minor(this, "No completion waiter");
                        // There weren't any transfers
                                allTransfersCompleted = true;
                }
@@ -602,7 +603,7 @@

        private void makeCompletionWaiter() {
                synchronized(this) {
-                       if(cw != null)
+                       if(cw == null)
                                cw = new CompletionWaiter();
                        else
                                return;
@@ -668,6 +669,7 @@
                                        }
                                        if(waitForCompletedTransfers(waiters, 
timeout, noTimeLeft)) {
                                                
synchronized(CHKInsertSender.this) {
+                                                       Logger.minor(this, "All 
transfers completed (1) on "+uid);
                                                        allTransfersCompleted = 
true;
                                                        
CHKInsertSender.this.notifyAll();
                                                }
@@ -681,6 +683,7 @@
                                                        }
                                                }
                                                
synchronized(CHKInsertSender.this) {
+                                                       Logger.minor(this, "All 
transfers completed (2) on "+uid);
                                                        allTransfersCompleted = 
true;
                                                        
CHKInsertSender.this.notifyAll();
                                                }
@@ -748,6 +751,7 @@
                                                                
waiters[i].completedTransfer(false);
                                                }
                                                
synchronized(CHKInsertSender.this) {
+                                                       Logger.minor(this, "All 
transfers completed (2) on "+uid);
                                                        transferTimedOut = true;
                                                        allTransfersCompleted = 
true;
                                                        
CHKInsertSender.this.notifyAll();
@@ -774,6 +778,7 @@
                                if(!completedTransfers) {
                                        try {
                                                if(!noTimeLeft) {
+                                                       Logger.minor(this, 
"Waiting for completion ("+timeout+"ms)");
                                                        
nodesWaitingForCompletion.wait(timeout);
                                                } else {
                                                        // Timed out
@@ -793,7 +798,7 @@
                        }
                        if(completedTransfers) {
                                // All done!
-                               Logger.minor(this, "Completed, 
status="+getStatusString()+", nothing left to wait for.");
+                               Logger.minor(this, "Completed, 
status="+getStatusString()+", nothing left to wait for for "+uid+" .");
                                synchronized(CHKInsertSender.this) {
                                        allTransfersCompleted = true;
                                        CHKInsertSender.this.notifyAll();

Modified: trunk/freenet/src/freenet/node/Version.java
===================================================================
--- trunk/freenet/src/freenet/node/Version.java 2006-07-08 14:10:46 UTC (rev 
9509)
+++ trunk/freenet/src/freenet/node/Version.java 2006-07-08 19:30:00 UTC (rev 
9510)
@@ -18,11 +18,11 @@
        public static final String protocolVersion = "1.0";

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

        /** Oldest build of Fred we will talk to */
        private static final int oldLastGoodBuild = 844;
-       private static final int newLastGoodBuild = 865;
+       private static final int newLastGoodBuild = 866;
        private static final long transitionTime = 1152403200000L; // 0:00 GMT 
30/06/06

        public static final int buildNumber() {

Modified: trunk/freenet/src/freenet/support/TokenBucket.java
===================================================================
--- trunk/freenet/src/freenet/support/TokenBucket.java  2006-07-08 14:10:46 UTC 
(rev 9509)
+++ trunk/freenet/src/freenet/support/TokenBucket.java  2006-07-08 19:30:00 UTC 
(rev 9510)
@@ -94,6 +94,7 @@
                        current = 0;
                } else if(current < 0) {
                        extra = -current;
+                       Logger.minor(this, "Neutralizing debt: "+extra);
                        current = 0;
                }
                long minDelayNS = nanosPerTick * (tokens + extra);
@@ -102,8 +103,14 @@

                // Schedule between the blockingGrab's.

-               if(nextWake < now) nextWake = now;
-               long wakeAt = (nextWake += minDelayMS);
+               if(nextWake < now) {
+                       Logger.minor(this, "Resetting nextWake to now");
+                       nextWake = now;
+               }
+               Logger.minor(this, "nextWake: "+(nextWake - now)+"ms");
+               long wakeAt = nextWake + minDelayMS;
+               nextWake = wakeAt;
+               Logger.minor(this, "nextWake now: "+(nextWake - now)+"ms");
                while(true) {
                        now = System.currentTimeMillis();
                        int delay = (int) Math.min(Integer.MAX_VALUE, wakeAt - 
now);


Reply via email to