I had just translated this bug to the prioritized queue... I kept the  
logic the same, but I knew it didn't look right!

All messages requeued in the past before r17024 (which is to say, a  
lot of messages, because nodes are busy), are requeued in the reverse  
order. Statistically, they may be requeued again (and flipped back).

With this bug gone (plus the priority queue) the insanely-long-request- 
searching has vanished!

--
Robert Hailey

On Jan 11, 2008, at 5:45 PM, robert at freenetproject.org wrote:

> Author: robert
> Date: 2008-01-11 23:45:09 +0000 (Fri, 11 Jan 2008)
> New Revision: 17024
>
> Modified:
>   trunk/freenet/src/freenet/node/PeerNode.java
> Log:
> requeue messages in the correct order... *long-standing-bug*
>
>
> Modified: trunk/freenet/src/freenet/node/PeerNode.java
> ===================================================================
> --- trunk/freenet/src/freenet/node/PeerNode.java      2008-01-11 23:22:03  
> UTC (rev 17023)
> +++ trunk/freenet/src/freenet/node/PeerNode.java      2008-01-11 23:45:09  
> UTC (rev 17024)
> @@ -999,6 +999,25 @@
>       }
>       
>       /**
> +      * like enqueuePrioritizedMessageItem, but adds it to the front of  
> those in the same priority.
> +      */
> +     private void pushfrontPrioritizedMessageItem(MessageItem addMe) {
> +             synchronized (messagesToSendNow) {
> +                     //Assume it goes on the end, both the common case and 
> an  
> accelerator for requeueing.
> +                     ListIterator  
> i=messagesToSendNow.listIterator(messagesToSendNow.size());
> +                     while (i.hasPrevious()) {
> +                             MessageItem here=(MessageItem)i.previous();
> +                             //While the item we are adding is NOT-LESS-THAN 
> priority, move  
> on (backwards...)
> +                             if (!(addMe.getPriority() <= 
> here.getPriority())) {
> +                                     i.next();
> +                                     break;
> +                             }
> +                     }
> +                     i.add(addMe);
> +             }
> +     }       
> +     
> +     /**
>        * Returns the number of milliseconds that it is estimated to take  
> to transmit the currently queued packets.
>        */
>       public long getProbableSendQueueTime() {
> @@ -1186,7 +1205,7 @@
>               synchronized(messagesToSendNow) {
>                       for(int i = offset; i < offset + length; i++)
>                               if(messages[i] != null)
> -                                     
> enqueuePrioritizedMessageItem(messages[i]);
> +                                     
> pushfrontPrioritizedMessageItem(messages[i]);
>               }
>       }
>
>
> _______________________________________________
> cvs mailing list
> cvs at freenetproject.org
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs
>


Reply via email to