Author: toad
Date: 2008-07-16 22:05:23 +0000 (Wed, 16 Jul 2008)
New Revision: 21149
Modified:
branches/db4o/freenet/src/freenet/node/RequestStarter.java
branches/db4o/freenet/src/freenet/node/SendableGet.java
Log:
Call removeFetchingKey() from RequestStarter only if something is thrown.
Otherwise, SendableRequest.send() is responsible for removing the ChosenRequest.
Modified: branches/db4o/freenet/src/freenet/node/RequestStarter.java
===================================================================
--- branches/db4o/freenet/src/freenet/node/RequestStarter.java 2008-07-16
21:26:12 UTC (rev 21148)
+++ branches/db4o/freenet/src/freenet/node/RequestStarter.java 2008-07-16
22:05:23 UTC (rev 21149)
@@ -275,8 +275,11 @@
}
if(Logger.shouldLog(Logger.MINOR, this))
Logger.minor(this, "Finished "+req);
- } finally {
- sched.removeFetchingKey(key, req);
+ } catch (Throwable t) {
+ // Remove it if something is thrown.
+ // But normally send() will remove it.
+ Logger.error(this, "Caught "+t, t);
+ sched.removeFetchingKey(key, req);
}
}
Modified: branches/db4o/freenet/src/freenet/node/SendableGet.java
===================================================================
--- branches/db4o/freenet/src/freenet/node/SendableGet.java 2008-07-16
21:26:12 UTC (rev 21148)
+++ branches/db4o/freenet/src/freenet/node/SendableGet.java 2008-07-16
22:05:23 UTC (rev 21149)
@@ -60,6 +60,7 @@
}
/** Do the request, blocking. Called by RequestStarter.
+ * Also responsible for deleting it.
* @return True if a request was executed. False if caller should try
to find another request, and remove
* this one from the queue. */
public boolean send(NodeClientCore core, final RequestScheduler sched,
ChosenRequest req) {
@@ -89,8 +90,12 @@
sched.callFailure(this, new
LowLevelGetException(LowLevelGetException.INTERNAL_ERROR), keyNum,
NativeThread.HIGH_PRIORITY, req, req.isPersistent());
return true;
}
+ // We must remove the request even in this case.
+ // On other paths, callFailure() will do the removal.
+ sched.removeFetchingKey(key.getNodeKey(), req);
// Don't call onSuccess(), it will be called for us by
backdoor coalescing.
sched.succeeded(this, req);
+
} catch (Throwable t) {
Logger.error(this, "Caught "+t, t);
sched.callFailure(this, new
LowLevelGetException(LowLevelGetException.INTERNAL_ERROR), keyNum,
NativeThread.HIGH_PRIORITY, req, req.isPersistent());