Author: toad
Date: 2008-03-20 16:41:48 +0000 (Thu, 20 Mar 2008)
New Revision: 18641

Modified:
   trunk/freenet/src/freenet/node/FNPPacketMangler.java
   trunk/freenet/src/freenet/node/PeerNode.java
Log:
Only report bytes if the connection is throttleable.

Modified: trunk/freenet/src/freenet/node/FNPPacketMangler.java
===================================================================
--- trunk/freenet/src/freenet/node/FNPPacketMangler.java        2008-03-20 
16:14:57 UTC (rev 18640)
+++ trunk/freenet/src/freenet/node/FNPPacketMangler.java        2008-03-20 
16:41:48 UTC (rev 18641)
@@ -1681,12 +1681,14 @@
                sock.sendPacket(data, replyTo, pn == null ? 
crypto.config.alwaysAllowLocalAddresses() : pn.allowLocalAddresses());
                if(pn != null)
                        pn.reportOutgoingPacket(data, 0, data.length, 
System.currentTimeMillis());
+               if(PeerNode.shouldThrottle(replyTo, node)) {
                int reportableBytes = data.length - alreadyReportedBytes;
                if(reportableBytes < 0) {
                        Logger.error(this, "alreadyReportedBytes 
("+alreadyReportedBytes+")> data.length ("+data.length+")");
                        reportableBytes = 0;
                }
                node.outputThrottle.forceGrab(reportableBytes);
+               }
        }

        /**

Modified: trunk/freenet/src/freenet/node/PeerNode.java
===================================================================
--- trunk/freenet/src/freenet/node/PeerNode.java        2008-03-20 16:14:57 UTC 
(rev 18640)
+++ trunk/freenet/src/freenet/node/PeerNode.java        2008-03-20 16:41:48 UTC 
(rev 18641)
@@ -3777,7 +3777,10 @@
        }

        public boolean shouldThrottle() {
-               Peer peer = getPeer();
+               return shouldThrottle(getPeer(), node);
+       }
+       
+       public static boolean shouldThrottle(Peer peer, Node node) {
                if(node.throttleLocalData) return true;
                if(peer == null) return true; // presumably
                return IPUtil.isValidAddress(peer.getAddress(), false);


Reply via email to