On Thursday 10 January 2008 19:23, robert at freenetproject.org wrote:
> Author: robert
> Date: 2008-01-10 19:23:00 +0000 (Thu, 10 Jan 2008)
> New Revision: 16997
>
> Modified:
> trunk/freenet/src/freenet/io/comm/RetrievalException.java
> trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java
> Log:
> tell the reciever if we are not transmitting anymore, and why
>
>
> Modified: trunk/freenet/src/freenet/io/comm/RetrievalException.java
> ===================================================================
> --- trunk/freenet/src/freenet/io/comm/RetrievalException.java 2008-01-10
19:19:20 UTC (rev 16996)
> +++ trunk/freenet/src/freenet/io/comm/RetrievalException.java 2008-01-10
19:23:00 UTC (rev 16997)
> @@ -40,6 +40,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
> + public static final int RECEIVER_DIED = 11;
>
> int _reason;
> String _cause;
> @@ -50,7 +51,7 @@
> }
>
> public RetrievalException(int reason, String cause) {
> - this(reason);
> + _reason = reason;
> _cause = cause;
> if (cause==null || cause.length()==0 || cause.equals("null"))
> _cause=getErrString(reason);
>
> Modified: trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java
> ===================================================================
> --- trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java 2008-01-10
19:19:20 UTC (rev 16996)
> +++ trunk/freenet/src/freenet/io/xfer/BlockTransmitter.java 2008-01-10
19:23:00 UTC (rev 16997)
> @@ -30,6 +30,7 @@
> import freenet.io.comm.MessageFilter;
> import freenet.io.comm.NotConnectedException;
> import freenet.io.comm.PeerContext;
> +import freenet.io.comm.RetrievalException;
> import freenet.node.PeerNode;
> import freenet.support.BitArray;
> import freenet.support.DoubleTokenBucket;
> @@ -208,6 +209,7 @@
> _sendComplete = true;
> _senderThread.notifyAll();
> }
> + sendAborted(_prb.getAbortedReason(),
> "Downstream transfer failed");
> return false;
> }
> Message msg;
> @@ -219,20 +221,20 @@
> msg =
_usm.waitFor(mfMissingPacketNotification.or(mfAllReceived.or(mfSendAborted)),
_ctr);
> if(logMINOR) Logger.minor(this, "Got
> "+msg);
> } catch (DisconnectedException e) {
> - // Ignore, see below
> - msg = null;
> - }
> - if(logMINOR) Logger.minor(this, "Got "+msg);
> - if(!_destination.isConnected()) {
> Logger.normal(this, "Terminating send
> "+_uid+" to "+_destination+"
from "+_destination.getSocketHandler()+" because node disconnected while
waiting");
> synchronized(_senderThread) {
> _sendComplete = true;
> _senderThread.notifyAll();
> }
> + //They disconnected, can't send an
> abort to them then can we?
> return false;
> }
Is this part (above) an improvement?
> - if(_sendComplete)
> + if(logMINOR) Logger.minor(this, "Got "+msg);
> + if(_sendComplete) {
> + Logger.normal(this, "send cancelled by
> _senderThread");
> + //_senderThread will have sent an
> aborted message
> return false;
> + }
> if (msg == null) {
> long now = System.currentTimeMillis();
> //SEND_TIMEOUT (one minute) after all
> packets have been transmitted,
terminate the send.
> @@ -242,7 +244,9 @@
> _sendComplete = true;
>
> _senderThread.notifyAll();
> }
> - Logger.error(this, "Terminating
> send "+_uid+" to "+_destination+"
from "+_destination.getSocketHandler()+" as we haven't heard from receiver
in "+TimeUtil.formatTime((now - timeAllSent), 2, true)+ '.');
> + String
> timeString=TimeUtil.formatTime((now - timeAllSent), 2, true);
> + Logger.error(this, "Terminating
> send "+_uid+" to "+_destination+"
from "+_destination.getSocketHandler()+" as we haven't heard from receiver
in "+timeString+ '.');
> +
> sendAborted(RetrievalException.RECEIVER_DIED, "Haven't heard from you
(receiver) in "+timeString);
> return false;
> } else {
> if(logMINOR) Logger.minor(this,
> "Ignoring timeout:
timeAllSent="+timeAllSent+" ("+(System.currentTimeMillis() - timeAllSent)+"),
getNumSent="+getNumSent()+ '/' +_prb.getNumPackets());
> @@ -276,18 +280,30 @@
> _sendComplete = true;
> _senderThread.notifyAll();
> }
> + //They aborted, don't need to send an
> aborted back :)
> return false;
> } else {
> Logger.error(this, "Transmitter
> received unknown message
type: "+msg.getSpec().getName());
> }
> }
> + } catch (NotConnectedException e) {
> + //most likely from sending an abort()
> + Logger.normal(this, "NotConnectedException in
> BlockTransfer.send():"+e);
> + return false;
> } catch (AbortedException e) {
> - // Terminate
> + Logger.normal(this, "AbortedException in
> BlockTransfer.send():"+e);
> + try {
> +
> sendAborted(RetrievalException.CANCELLED_BY_RECEIVER, "Downstream
transfer failed");
> + } catch (NotConnectedException gone) {
> + //ignore
> + }
> + return false;
> + } finally {
> + //Terminate, if we are not listening for control
> packets, don't be
sending any data
> synchronized(_senderThread) {
> _sendComplete = true;
> _senderThread.notifyAll();
> - }
> - return false;
> + }
> }
> }
>
>
> _______________________________________________
> cvs mailing list
> cvs at freenetproject.org
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL:
<https://emu.freenetproject.org/pipermail/devl/attachments/20080112/739c2735/attachment.pgp>