Author: toad
Date: 2008-02-07 11:43:52 +0000 (Thu, 07 Feb 2008)
New Revision: 17647

Modified:
   trunk/freenet/src/freenet/client/async/OfferedKeysList.java
   trunk/freenet/src/freenet/node/Node.java
   trunk/freenet/src/freenet/node/NodeClientCore.java
   trunk/freenet/src/freenet/node/RequestHandler.java
   trunk/freenet/src/freenet/node/RequestSender.java
Log:
When sending a request-for-an-offered-key from OfferedKeysList, don't allow the 
request to be routed properly, ONLY try the offering nodes (with short 
timeouts).

Modified: trunk/freenet/src/freenet/client/async/OfferedKeysList.java
===================================================================
--- trunk/freenet/src/freenet/client/async/OfferedKeysList.java 2008-02-07 
11:24:30 UTC (rev 17646)
+++ trunk/freenet/src/freenet/client/async/OfferedKeysList.java 2008-02-07 
11:43:52 UTC (rev 17647)
@@ -95,7 +95,11 @@

        public boolean send(NodeClientCore node, RequestScheduler sched, Object 
keyNum) {
                Key key = (Key) keyNum;
-               core.asyncGet(key, true);// Have to cache it in order to 
propagate it; FIXME
+               // Have to cache it in order to propagate it; FIXME
+               // Don't let a node force us to start a real request for a 
specific key.
+               // We check the datastore, take up offers if any (on a short 
timeout), and then quit if we still haven't fetched the data.
+               // Obviously this may have a marginal impact on load but it 
should only be marginal.
+               core.asyncGet(key, true, true);
                return true;
        }


Modified: trunk/freenet/src/freenet/node/Node.java
===================================================================
--- trunk/freenet/src/freenet/node/Node.java    2008-02-07 11:24:30 UTC (rev 
17646)
+++ trunk/freenet/src/freenet/node/Node.java    2008-02-07 11:43:52 UTC (rev 
17647)
@@ -1786,7 +1786,7 @@
         * a RequestSender, unless the HTL is 0, in which case NULL.
         * RequestSender.
         */
-       public Object makeRequestSender(Key key, short htl, long uid, PeerNode 
source, double closestLocation, boolean resetClosestLocation, boolean 
localOnly, boolean cache, boolean ignoreStore) {
+       public Object makeRequestSender(Key key, short htl, long uid, PeerNode 
source, double closestLocation, boolean resetClosestLocation, boolean 
localOnly, boolean cache, boolean ignoreStore, boolean offersOnly) {
                logMINOR = Logger.shouldLog(Logger.MINOR, this);
                if(logMINOR) Logger.minor(this, "makeRequestSender("+key+ ',' 
+htl+ ',' +uid+ ',' +source+") on "+getDarknetPortNumber());
                // In store?
@@ -1845,7 +1845,7 @@
                        // 0 timeout so it doesn't prevent future requests), 
and send it the data 
                        // through ULPRs if it is found.

-                       sender = new RequestSender(key, null, htl, uid, this, 
closestLocation, resetClosestLocation, source);
+                       sender = new RequestSender(key, null, htl, uid, this, 
closestLocation, resetClosestLocation, source, offersOnly);
                        // RequestSender adds itself to requestSenders
                }
                sender.start();

Modified: trunk/freenet/src/freenet/node/NodeClientCore.java
===================================================================
--- trunk/freenet/src/freenet/node/NodeClientCore.java  2008-02-07 11:24:30 UTC 
(rev 17646)
+++ trunk/freenet/src/freenet/node/NodeClientCore.java  2008-02-07 11:43:52 UTC 
(rev 17647)
@@ -444,14 +444,14 @@
         * anything and will run asynchronously.
         * @param key
         */
-       public void asyncGet(Key key, boolean cache) {
+       public void asyncGet(Key key, boolean cache, boolean offersOnly) {
                long uid = random.nextLong();
                if(!node.lockUID(uid, false, false, false)) {
                        Logger.error(this, "Could not lock UID just randomly 
generated: "+uid+" - probably indicates broken PRNG");
                        return;
                }
                try {
-                       Object o = node.makeRequestSender(key, node.maxHTL(), 
uid, null, node.getLocation(), false, false, cache, false);
+                       Object o = node.makeRequestSender(key, node.maxHTL(), 
uid, null, node.getLocation(), false, false, cache, false, offersOnly);
                        if(o instanceof CHKBlock) {
                                return; // Already have it.
                        }
@@ -485,7 +485,7 @@
                        throw new 
LowLevelGetException(LowLevelGetException.INTERNAL_ERROR);
                }
                try {
-               Object o = node.makeRequestSender(key.getNodeCHK(), 
node.maxHTL(), uid, null, node.getLocation(), false, localOnly, cache, 
ignoreStore);
+               Object o = node.makeRequestSender(key.getNodeCHK(), 
node.maxHTL(), uid, null, node.getLocation(), false, localOnly, cache, 
ignoreStore, false);
                if(o instanceof CHKBlock) {
                        try {
                                return new ClientCHKBlock((CHKBlock)o, key);
@@ -600,7 +600,7 @@
                        throw new 
LowLevelGetException(LowLevelGetException.INTERNAL_ERROR);
                }
                try {
-               Object o = node.makeRequestSender(key.getNodeKey(), 
node.maxHTL(), uid, null, node.getLocation(), false, localOnly, cache, 
ignoreStore);
+               Object o = node.makeRequestSender(key.getNodeKey(), 
node.maxHTL(), uid, null, node.getLocation(), false, localOnly, cache, 
ignoreStore, false);
                if(o instanceof SSKBlock) {
                        try {
                                SSKBlock block = (SSKBlock)o;

Modified: trunk/freenet/src/freenet/node/RequestHandler.java
===================================================================
--- trunk/freenet/src/freenet/node/RequestHandler.java  2008-02-07 11:24:30 UTC 
(rev 17646)
+++ trunk/freenet/src/freenet/node/RequestHandler.java  2008-02-07 11:43:52 UTC 
(rev 17647)
@@ -140,7 +140,7 @@
         Message accepted = DMT.createFNPAccepted(uid);
         source.sendAsync(accepted, null, 0, this);

-        Object o = node.makeRequestSender(key, htl, uid, source, closestLoc, 
resetClosestLoc, false, true, false);
+        Object o = node.makeRequestSender(key, htl, uid, source, closestLoc, 
resetClosestLoc, false, true, false, false);
         if(o instanceof KeyBlock) {
                returnLocalData((KeyBlock)o);
             return;

Modified: trunk/freenet/src/freenet/node/RequestSender.java
===================================================================
--- trunk/freenet/src/freenet/node/RequestSender.java   2008-02-07 11:24:30 UTC 
(rev 17646)
+++ trunk/freenet/src/freenet/node/RequestSender.java   2008-02-07 11:43:52 UTC 
(rev 17647)
@@ -146,7 +146,7 @@
      * already; RequestSender will not look it up.
      */
     public RequestSender(Key key, DSAPublicKey pubKey, short htl, long uid, 
Node n, double nearestLoc, boolean resetNearestLoc, 
-            PeerNode source) {
+            PeerNode source, boolean offersOnly) {
         this.key = key;
         this.pubKey = pubKey;
         this.htl = htl;
@@ -155,6 +155,7 @@
         this.source = source;
         this.nearestLoc = nearestLoc;
         this.resetNearestLoc = resetNearestLoc;
+        this.tryOffersOnly = offersOnly;
         target = key.toNormalizedDouble();
         node.addRequestSender(key, htl, this);
         logMINOR = Logger.shouldLog(Logger.MINOR, this);
@@ -373,6 +374,12 @@
         }
         }

+        if(tryOffersOnly) {
+               if(logMINOR) Logger.minor(this, "Tried all offers, not doing a 
regular request for key");
+               finish(DATA_NOT_FOUND, null, true); // FIXME need a different 
error code?
+               return;
+        }
+        
                int routeAttempts=0;
                int rejectOverloads=0;
         HashSet nodesRoutedTo = new HashSet();


Reply via email to