Author: robert
Date: 2008-01-10 00:33:13 +0000 (Thu, 10 Jan 2008)
New Revision: 16990

Modified:
   trunk/freenet/src/freenet/io/xfer/BlockReceiver.java
Log:
tell the transmitter if we are not listening anymore, and why


Modified: trunk/freenet/src/freenet/io/xfer/BlockReceiver.java
===================================================================
--- trunk/freenet/src/freenet/io/xfer/BlockReceiver.java        2008-01-10 
00:15:37 UTC (rev 16989)
+++ trunk/freenet/src/freenet/io/xfer/BlockReceiver.java        2008-01-10 
00:33:13 UTC (rev 16990)
@@ -51,6 +51,7 @@
        /** packet : Integer -> reportTime : Long * */
        HashMap _recentlyReportedMissingPackets = new HashMap();
        ByteCounter _ctr;
+       boolean sentAborted;

        public BlockReceiver(MessageCore usm, PeerContext sender, long uid, 
PartiallyReceivedBlock prb, ByteCounter ctr) {
                _sender = sender;
@@ -62,6 +63,7 @@

        public void sendAborted(int reason, String desc) throws 
NotConnectedException {
                _usm.send(_sender, DMT.createSendAborted(_uid, reason, desc), 
_ctr);
+               sentAborted=true;
        }

        public byte[] receive() throws RetrievalException {
@@ -153,6 +155,14 @@
                        // We didn't cause it?!
                        Logger.error(this, "Caught in receive - probably a bug 
as receive sets it: "+e);
                        throw new 
RetrievalException(RetrievalException.UNKNOWN, "Aborted?");
+               } finally {
+                       try {
+                               if (_prb.isAborted() && !sentAborted) {
+                                       sendAborted(_prb.getAbortReason(), 
_prb.getAbortDescription());
+                               }
+                       } catch (NotConnectedException e) {
+                               //ignore
+                       }
                }
        }
 }


Reply via email to