Author: toad
Date: 2007-11-27 01:20:10 +0000 (Tue, 27 Nov 2007)
New Revision: 15952

Modified:
   trunk/freenet/src/freenet/io/AddressTrackerItem.java
Log:
Just overwrite the first gap if we haven't responded yet.

Modified: trunk/freenet/src/freenet/io/AddressTrackerItem.java
===================================================================
--- trunk/freenet/src/freenet/io/AddressTrackerItem.java        2007-11-27 
01:05:11 UTC (rev 15951)
+++ trunk/freenet/src/freenet/io/AddressTrackerItem.java        2007-11-27 
01:20:10 UTC (rev 15952)
@@ -78,11 +78,15 @@
                if(timeFirstSentPacket > 0) startTime = timeFirstSentPacket;
                else startTime = timeDefinitelyNoPacketsSent;
                if(now - startTime > GAP_THRESHOLD) {
-                       // Rotate gaps array
-                       for(int i=1;i<TRACK_GAPS;i++) {
-                               topGapLengths[i] = topGapLengths[i-1];
-                               topGapLengthRecvTimes[i] = 
topGapLengthRecvTimes[i-1];
-                       }
+                       // Not necessarily a new gap
+                       // If no packets sent since last one, just replace it
+                       if(timeLastSentPacket > topGapLengthRecvTimes[0]) {
+                               // Rotate gaps array
+                               for(int i=1;i<TRACK_GAPS;i++) {
+                                       topGapLengths[i] = topGapLengths[i-1];
+                                       topGapLengthRecvTimes[i] = 
topGapLengthRecvTimes[i-1];
+                               }
+                       } // else overwrite [0]
                        topGapLengths[0] = (now - timeFirstSentPacket);
                        topGapLengthRecvTimes[0] = now;
                }
@@ -99,7 +103,7 @@

        public synchronized Gap[] getGaps() {
                Gap[] gaps = new Gap[GAP_THRESHOLD];
-               for(int i=0;i<GAP_THRESHOLD;i++) {
+               for(int i=0;i<TRACK_GAPS;i++) {
                        gaps[i] = new Gap(topGapLengths[i], 
topGapLengthRecvTimes[i]);
                }
                return gaps;


Reply via email to