[freenet-dev] [freenet-cvs] r16388 - trunk/freenet/src/freenet/client/async

Robert Hailey freenet-devl at osndok.com
Mon Dec 10 16:34:32 UTC 2007


On Dec 8, 2007, at 6:48 AM, Matthew Toseland wrote:

> On Friday 07 December 2007 02:13, you wrote:
>
> With regards to Timer: Why not just use the Ticker ? Admittedly they  
> will
> sometimes get scheduled in parallel, but iirc it doesn't do that  
> much work
> on-thread so it's not really a problem...

I was not aware of Ticker. It would seem to be more consistent with  
the code base to use Ticker.

>>
>> Modified: trunk/freenet/src/freenet/client/async/USKFetcher.java
>> ===================================================================
>> --- trunk/freenet/src/freenet/client/async/USKFetcher.java	2007-12-07
> 01:41:35 UTC (rev 16387)
>> +++ trunk/freenet/src/freenet/client/async/USKFetcher.java	2007-12-07
> 02:13:36 UTC (rev 16388)
>> @@ -252,43 +255,28 @@
>> 			long now = System.currentTimeMillis();
>> 			synchronized(this) {
>> 				started = false; // don't finish before have rescheduled
>> +
>> +                //Find out when we should check next ('end'), in an
> increasing delay (unless we make progress).
>> +                long newSleepTime = sleepTime * 2;
>> +				if(newSleepTime > maxSleepTime) newSleepTime = maxSleepTime;
>> +				sleepTime = newSleepTime;
>> +				end = now + sleepTime;
>> +
>> 				if(valAtEnd > valueAtSchedule) {
>> -					// Have advanced.
>> +					// We have advanced; keep trying as if we just started.
>> 					minFailures = origMinFailures;
>> 					sleepTime = origSleepTime;
>> +					end = now;
>
> end = now + origSleepTime. What you have there makes it retry  
> *immediately*.

Correct. If a USKFetch makes progress it must retry with a distinct  
window-of-five, and the original code appeared to do this immediately,  
so I maintained that. This code should only be executed when the very  
last fetch attempt is complete.

--
Robert Hailey




More information about the Devl mailing list