Author: toad
Date: 2008-01-28 16:25:22 +0000 (Mon, 28 Jan 2008)
New Revision: 17361

Modified:
   trunk/freenet/src/freenet/io/xfer/BulkTransmitter.java
Log:
Logging, toString()

Modified: trunk/freenet/src/freenet/io/xfer/BulkTransmitter.java
===================================================================
--- trunk/freenet/src/freenet/io/xfer/BulkTransmitter.java      2008-01-28 
16:25:05 UTC (rev 17360)
+++ trunk/freenet/src/freenet/io/xfer/BulkTransmitter.java      2008-01-28 
16:25:22 UTC (rev 17361)
@@ -160,6 +160,8 @@
        }

        public void cancel() {
+               if(Logger.shouldLog(Logger.MINOR, this))
+                       Logger.minor(this, "Cancelling "+this);
                sendAbortedMessage();
                synchronized(this) {
                        cancelled = true;
@@ -184,9 +186,14 @@
         * @return True if the file was successfully sent. False otherwise.
         */
        public boolean send() {
+               boolean logMINOR = Logger.shouldLog(Logger.MINOR, this);
                long lastSentPacket = System.currentTimeMillis();
                while(true) {
-                       if(prb.isAborted()) return false;
+                       if(prb.isAborted()) {
+                               if(logMINOR)
+                                       Logger.minor(this, "Aborted "+this);
+                               return false;
+                       }
                        int blockNo;
                        if(peer.getBootID() != peerBootID) {
                                synchronized(this) {
@@ -194,6 +201,8 @@
                                        notifyAll();
                                }
                                prb.remove(BulkTransmitter.this);
+                               if(logMINOR)
+                                       Logger.minor(this, "Failed to send 
"+uid+": peer restarted: "+peer);
                                return false;
                        }
                        synchronized(this) {
@@ -226,6 +235,8 @@
                        // Send a packet
                        byte[] buf = prb.getBlockData(blockNo);
                        if(buf == null) {
+                               if(logMINOR)
+                                       Logger.minor(this, "Block "+blockNo+" 
is null, presumably the send is cancelled: "+this);
                                // Already cancelled, quit
                                return false;
                        }
@@ -248,6 +259,8 @@
                                                }
                                                if(cancelled) {
                                                        
masterThrottle.recycle(packetSize);
+                                                       if(logMINOR)
+                                                               
Logger.minor(this, "Cancelled after sleeping for throttle "+this);
                                                        return false;
                                                }
                                        }
@@ -265,9 +278,14 @@
                                lastSentPacket = System.currentTimeMillis();
                        } catch (NotConnectedException e) {
                                cancel();
+                               if(logMINOR)
+                                       Logger.minor(this, "Canclled: not 
connected "+this);
                                return false;
                        }
                }
        }

+       public String toString() {
+               return "BulkTransmitter:"+uid+":"+peer.shortToString();
+       }
 }


Reply via email to