Author: toad
Date: 2008-04-02 19:55:49 +0000 (Wed, 02 Apr 2008)
New Revision: 18921
Modified:
trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
Log:
Prevent race condition resulting in losing blocks immediately after scheduling
them.
Modified: trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
===================================================================
--- trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
2008-04-02 17:11:56 UTC (rev 18920)
+++ trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
2008-04-02 19:55:49 UTC (rev 18921)
@@ -329,6 +329,9 @@
prio.add(clientGrabber);
if(logMINOR) Logger.minor(this, "Registering retry
count "+rc+" with prioclass "+priorityClass+" on "+clientGrabber+" for "+prio);
}
+ // SectoredRandomGrabArrayWithInt and lower down have
hierarchical locking and auto-remove.
+ // To avoid a race condition it is essential to mirror that
here.
+ synchronized(clientGrabber) {
// Request
SectoredRandomGrabArrayWithObject requestGrabber =
(SectoredRandomGrabArrayWithObject) clientGrabber.getGrabber(client);
if(requestGrabber == null) {
@@ -338,6 +341,7 @@
clientGrabber.addGrabber(client, requestGrabber);
}
requestGrabber.add(cr, req);
+ }
}
/**
@@ -492,7 +496,7 @@
// Whether it is running a
request, waiting to execute, or waiting on the
// cooldown queue, ULPRs and
backdoor coalescing should still be active.
}
- if(logMINOR) Logger.minor(this,
"removeFirst() returning "+req);
+ if(logMINOR) Logger.minor(this,
"removeFirst() returning "+req+" of "+req.getClientRequest());
return req;
}
}