Author: toad
Date: 2007-02-21 19:26:09 +0000 (Wed, 21 Feb 2007)
New Revision: 11884

Modified:
   trunk/freenet/src/freenet/client/async/SimpleSingleFileFetcher.java
   trunk/freenet/src/freenet/client/async/SingleFileFetcher.java
   trunk/freenet/src/freenet/node/SendableGet.java
Log:
Logging, try to catch some sort of deadlock (probably the one I just fixed!)

Modified: trunk/freenet/src/freenet/client/async/SimpleSingleFileFetcher.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SimpleSingleFileFetcher.java 
2007-02-21 19:23:58 UTC (rev 11883)
+++ trunk/freenet/src/freenet/client/async/SimpleSingleFileFetcher.java 
2007-02-21 19:26:09 UTC (rev 11884)
@@ -78,14 +78,18 @@

        // Real onFailure
        protected void onFailure(FetchException e, boolean forceFatal) {
+               boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
+               if(logMINOR) Logger.minor(this, "onFailure( "+e+" , 
"+forceFatal+")", e);
                if(parent.isCancelled() || cancelled) {
-                       if(Logger.shouldLog(Logger.MINOR, this)) 
-                               Logger.minor(this, "Failing: cancelled");
+                       if(logMINOR) Logger.minor(this, "Failing: cancelled");
                        e = new FetchException(FetchException.CANCELLED);
                        forceFatal = true;
                }
                if(!(e.isFatal() || forceFatal) ) {
-                       if(retry()) return;
+                       if(retry()) {
+                               if(logMINOR) Logger.minor(this, "Retrying");
+                               return;
+                       }
                }
                // :(
                if(e.isFatal() || forceFatal)

Modified: trunk/freenet/src/freenet/client/async/SingleFileFetcher.java
===================================================================
--- trunk/freenet/src/freenet/client/async/SingleFileFetcher.java       
2007-02-21 19:23:58 UTC (rev 11883)
+++ trunk/freenet/src/freenet/client/async/SingleFileFetcher.java       
2007-02-21 19:26:09 UTC (rev 11884)
@@ -122,6 +122,8 @@
                        onFailure(new 
FetchException(FetchException.INTERNAL_ERROR, "onSuccess(null) in "+this));
                        return; // failed
                }
+               if(logMINOR)
+                       Logger.minor(this, "Block "+(block.isMetadata() ? "is 
metadata" : "is not metadata")+" on "+this);
                if(!block.isMetadata()) {
                        onSuccess(new FetchResult(clientMetadata, data));
                } else {
@@ -166,6 +168,8 @@

        protected void onSuccess(FetchResult result) {
                if(parent.isCancelled()) {
+                       if(logMINOR)
+                               Logger.minor(this, "Parent is cancelled");
                        result.asBucket().free();
                        onFailure(new FetchException(FetchException.CANCELLED));
                        return;

Modified: trunk/freenet/src/freenet/node/SendableGet.java
===================================================================
--- trunk/freenet/src/freenet/node/SendableGet.java     2007-02-21 19:23:58 UTC 
(rev 11883)
+++ trunk/freenet/src/freenet/node/SendableGet.java     2007-02-21 19:26:09 UTC 
(rev 11884)
@@ -73,21 +73,27 @@
                                        if(logMINOR) Logger.minor(this, "No 
more keys: "+this);
                                        return false;
                                }
-                               ClientKey key = getKey(keyNum);
-                               if(key == null) {
-                                       if(logMINOR) Logger.minor(this, "No key 
"+keyNum+": "+this);
-                                       continue;
+                               try {
+                                       ClientKey key = getKey(keyNum);
+                                       if(key == null) {
+                                               if(logMINOR) Logger.minor(this, 
"No key "+keyNum+": "+this);
+                                               continue;
+                                       }
+                                       block = core.realGetKey(key, 
ctx.localRequestOnly, ctx.cacheLocalRequests, ctx.ignoreStore);
+                               } catch (LowLevelGetException e) {
+                                       onFailure(e, keyNum);
+                                       return true;
+                               } catch (Throwable t) {
+                                       Logger.error(this, "Caught "+t, t);
+                                       onFailure(new 
LowLevelGetException(LowLevelGetException.INTERNAL_ERROR), keyNum);
+                                       return true;
                                }
-                               block = core.realGetKey(key, 
ctx.localRequestOnly, ctx.cacheLocalRequests, ctx.ignoreStore);
-                       } catch (LowLevelGetException e) {
-                               onFailure(e, keyNum);
-                               return true;
+                               onSuccess(block, false, keyNum);
                        } catch (Throwable t) {
                                Logger.error(this, "Caught "+t, t);
                                onFailure(new 
LowLevelGetException(LowLevelGetException.INTERNAL_ERROR), keyNum);
                                return true;
                        }
-                       onSuccess(block, false, keyNum);
                        return true;
                }
        }


Reply via email to