Author: toad
Date: 2008-04-04 20:03:02 +0000 (Fri, 04 Apr 2008)
New Revision: 18990
Modified:
trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
Log:
Locking: simplify and prevent race conditions by simply synchronizing on (this)
in removeFirst().
Hopefully this won't cause any problems... addToGrabArray is already
synchronized(this).
Modified: trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
===================================================================
--- trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
2008-04-04 19:49:40 UTC (rev 18989)
+++ trunk/freenet/src/freenet/client/async/ClientRequestScheduler.java
2008-04-04 20:03:02 UTC (rev 18990)
@@ -387,7 +387,11 @@
return -1;
}
- public SendableRequest removeFirst() {
+ // LOCKING: Life is a good deal simpler if we just synchronize on
(this).
+ // We prevent a number of race conditions (e.g. adding a retry count
and then another
+ // thread removes it cos its empty) ... and in addToGrabArray etc we
already sync on this.
+ // The worry is ... is there any nested locking outside of the
hierarchy?
+ public synchronized SendableRequest removeFirst() {
// Priorities start at 0
if(logMINOR) Logger.minor(this, "removeFirst()");
boolean tryOfferedKeys = offeredKeys != null &&
node.random.nextBoolean();