Author: robert
Date: 2008-01-10 00:15:37 +0000 (Thu, 10 Jan 2008)
New Revision: 16989
Modified:
trunk/freenet/src/freenet/io/comm/RetrievalException.java
trunk/freenet/src/freenet/io/xfer/BlockReceiver.java
trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java
trunk/freenet/src/freenet/node/InsertHandler.java
trunk/freenet/src/freenet/node/RequestSender.java
Log:
pay attention to non-disconnect retrieve exceptions
Modified: trunk/freenet/src/freenet/io/comm/RetrievalException.java
===================================================================
--- trunk/freenet/src/freenet/io/comm/RetrievalException.java 2008-01-10
00:03:27 UTC (rev 16988)
+++ trunk/freenet/src/freenet/io/comm/RetrievalException.java 2008-01-10
00:15:37 UTC (rev 16989)
@@ -33,24 +33,27 @@
public static final int HTTP_404_RECEIVED = 1;
public static final int PREMATURE_EOF = 2;
public static final int IO_ERROR = 3;
- public static final int RANGE_UNSUPPORTED = 4;
public static final int SENDER_DIED = 5;
public static final int TIMED_OUT = 4;
public static final int ALREADY_CACHED = 6;
public static final int SENDER_DISCONNECTED = 7;
public static final int NO_DATAINSERT = 8;
public static final int CANCELLED_BY_RECEIVER = 9;
+ public static final int RANGE_UNSUPPORTED = 10; //was 4
int _reason;
String _cause;
public RetrievalException(int reason) {
_reason = reason;
+ _cause = getErrString(reason);
}
public RetrievalException(int reason, String cause) {
this(reason);
_cause = cause;
+ if (cause==null || cause.length()==0 || cause.equals("null"))
+ _cause=getErrString(reason);
}
public int getReason() {
@@ -60,4 +63,33 @@
public String toString() {
return _cause;
}
+
+ public static String getErrString(int reason) {
+ switch (reason) {
+ case HTTP_404_RECEIVED:
+ return "HTTP_404_RECEIVED";
+ case PREMATURE_EOF:
+ return "PREMATURE_EOF";
+ case IO_ERROR:
+ return "IO_ERROR";
+ case RANGE_UNSUPPORTED:
+ return "RANGE_UNSUPPORTED";
+ case SENDER_DIED:
+ return "SENDER_DIED";
+ case TIMED_OUT: // was the same as RANGE_UNSUPPORTED
+ return "TIMED_OUT/RANGE_UNSUPPORTED";
+ case ALREADY_CACHED:
+ return "ALREADY_CACHED";
+ case SENDER_DISCONNECTED:
+ return "SENDER_DISCONNECTED";
+ case NO_DATAINSERT:
+ return "NO_DATAINSERT";
+ case CANCELLED_BY_RECEIVER:
+ return "CANCELLED_BY_RECEIVER";
+ case UNKNOWN:
+ return "UNKNOWN";
+ default:
+ return "UNKNOWN ("+reason+")";
+ }
+ }
}
Modified: trunk/freenet/src/freenet/io/xfer/BlockReceiver.java
===================================================================
--- trunk/freenet/src/freenet/io/xfer/BlockReceiver.java 2008-01-10
00:03:27 UTC (rev 16988)
+++ trunk/freenet/src/freenet/io/xfer/BlockReceiver.java 2008-01-10
00:15:37 UTC (rev 16989)
@@ -78,7 +78,7 @@
if(!_sender.isConnected()) throw new DisconnectedException();
} catch (DisconnectedException e1) {
Logger.normal(this, "Disconnected during receive: "+_uid+"
from "+_sender);
- _prb.abort(RetrievalException.SENDER_DIED, "Disconnected
during receive");
+ _prb.abort(RetrievalException.SENDER_DISCONNECTED,
"Disconnected during receive");
throw new
RetrievalException(RetrievalException.SENDER_DISCONNECTED);
}
if(logMINOR)
@@ -152,7 +152,7 @@
} catch(AbortedException e) {
// We didn't cause it?!
Logger.error(this, "Caught in receive - probably a bug
as receive sets it: "+e);
- throw new
RetrievalException(RetrievalException.UNKNOWN);
+ throw new
RetrievalException(RetrievalException.UNKNOWN, "Aborted?");
}
}
}
Modified: trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java
===================================================================
--- trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java 2008-01-10
00:03:27 UTC (rev 16988)
+++ trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java 2008-01-10
00:15:37 UTC (rev 16989)
@@ -156,6 +156,9 @@
// Report the delay caused by bandwidth
limiting, NOT the delay caused by congestion control.
((PeerNode)_destination).reportThrottledPacketSendTime(delayTime);
+ if (end - now > 2*60*1000)
+ Logger.error(this, "per-packet
congestion control delay: "+(end-now));
+
if(now > end) return;
while(now < end) {
long l = end - now;
Modified: trunk/freenet/src/freenet/node/InsertHandler.java
===================================================================
--- trunk/freenet/src/freenet/node/InsertHandler.java 2008-01-10 00:03:27 UTC
(rev 16988)
+++ trunk/freenet/src/freenet/node/InsertHandler.java 2008-01-10 00:15:37 UTC
(rev 16989)
@@ -442,7 +442,10 @@
//If they are not connected, that's
probably why the receive failed!
if (logMINOR) Logger.minor(this, "Can't send "+msg+" to
"+source+": "+ex);
}
- if(logMINOR) Logger.minor(this, "Failed to retrieve: "+e, e);
+ if
(e.getReason()==RetrievalException.SENDER_DISCONNECTED)
+ Logger.normal(this, "Failed to
retrieve: "+e, e);
+ else
+ Logger.error(this, "Failed to retrieve:
"+e, e);
return;
} catch (Throwable t) {
Logger.error(this, "Caught "+t, t);
Modified: trunk/freenet/src/freenet/node/RequestSender.java
===================================================================
--- trunk/freenet/src/freenet/node/RequestSender.java 2008-01-10 00:03:27 UTC
(rev 16988)
+++ trunk/freenet/src/freenet/node/RequestSender.java 2008-01-10 00:15:37 UTC
(rev 16989)
@@ -483,7 +483,10 @@
finish(SUCCESS, next);
return;
} catch (RetrievalException e) {
- Logger.normal(this, "Transfer failed:
"+e, e);
+ if
(e.getReason()==RetrievalException.SENDER_DISCONNECTED)
+
Logger.normal(this, "Transfer failed: "+e, e);
+ else
+
Logger.error(this, "Transfer failed: "+e, e);
finish(TRANSFER_FAILED, next);
return;
}