Author: nextgens
Date: 2006-08-03 13:17:15 +0000 (Thu, 03 Aug 2006)
New Revision: 9851
Modified:
trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
Log:
Restore a test I got rid of whereas I shouldn't had.
If we are changing the request's priority somewhere without calling
reregisterAll(), it can lead to unexpected behaviours
Modified: trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
===================================================================
--- trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
2006-08-02 16:59:22 UTC (rev 9850)
+++ trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
2006-08-03 13:17:15 UTC (rev 9851)
@@ -208,9 +208,8 @@
clientGrabber.add(cr, req);
}
- private SortedVectorByNumber removeFirstAccordingToPriorities(){
+ private SortedVectorByNumber removeFirstAccordingToPriorities(int
priority){
SortedVectorByNumber result = null;
- int priority;
short fuzz = -1, iteration = 0;
synchronized (this) {
@@ -242,7 +241,8 @@
public SendableRequest removeFirst() {
// Priorities start at 0
Logger.minor(this, "removeFirst()");
- SortedVectorByNumber s = removeFirstAccordingToPriorities();
+ int choosenPriorityClass = Integer.MAX_VALUE;
+ SortedVectorByNumber s =
removeFirstAccordingToPriorities(choosenPriorityClass);
if(s != null){
while(true) {
SectoredRandomGrabArrayWithInt rga =
(SectoredRandomGrabArrayWithInt) s.getFirst();
@@ -261,6 +261,12 @@
if(req == null) {
Logger.minor(this, "No requests,
retrycount "+rga.getNumber()+" ("+rga+")");
break;
+ }else if(req.getPriorityClass() >
choosenPriorityClass) {
+ // Reinsert it : shouldn't happen if we
are calling reregisterAll,
+ // maybe we should ask people to report
that error if seen
+ Logger.minor(this, "In wrong priority
class: "+req);
+ innerRegister(req);
+ continue;
}
Logger.minor(this, "removeFirst() returning
"+req+" ("+rga.getNumber()+")");