Author: toad
Date: 2007-06-04 23:16:55 +0000 (Mon, 04 Jun 2007)
New Revision: 13468

Modified:
   trunk/freenet/src/freenet/node/PacketSender.java
Log:
Don't send a notifications only packet if we could have sent a packet with 
payload!

Modified: trunk/freenet/src/freenet/node/PacketSender.java
===================================================================
--- trunk/freenet/src/freenet/node/PacketSender.java    2007-06-04 23:09:41 UTC 
(rev 13467)
+++ trunk/freenet/src/freenet/node/PacketSender.java    2007-06-04 23:16:55 UTC 
(rev 13468)
@@ -198,19 +198,15 @@
                     continue;
                 }

+                boolean mustSend = false;
+                
                 // Any urgent notifications to send?
                 long urgentTime = pn.getNextUrgentTime();
                 // Should spam the logs, unless there is a deadlock
                 if(urgentTime < Long.MAX_VALUE && logMINOR)
                        Logger.minor(this, "Next urgent time: "+urgentTime+" 
for "+pn.getPeer());
                 if(urgentTime <= now) {
-                    // Send them
-                    try {
-                                               pn.sendAnyUrgentNotifications();
-                                       } catch (PacketSequenceException e) {
-                       Logger.error(this, "Caught "+e+" - while sending urgent 
notifications : disconnecting", e);
-                       pn.forceDisconnect();
-                                       }
+                       mustSend = true;
                 } else {
                     nextActionTime = Math.min(nextActionTime, urgentTime);
                 }
@@ -231,6 +227,7 @@
                         try {
                             if(logMINOR) Logger.minor(this, "Resending 
"+item.packetNumber+" to "+item.kt);
                             node.packetMangler.resend(item);
+                            mustSend = false;
                         } catch (KeyChangedException e) {
                             Logger.error(this, "Caught "+e+" resending packets 
to "+kt);
                             pn.requeueResendItems(rpiTemp);
@@ -274,10 +271,21 @@
                                }
                                // Send packets, right now, blocking, including 
any active notifications
                                
node.packetMangler.processOutgoingOrRequeue(messages, pn, true, false);
+                               mustSend = false;
                                continue;
                        }
                 }

+                if(mustSend) {
+                    // Send them
+                    try {
+                                               pn.sendAnyUrgentNotifications();
+                                       } catch (PacketSequenceException e) {
+                       Logger.error(this, "Caught "+e+" - while sending urgent 
notifications : disconnecting", e);
+                       pn.forceDisconnect();
+                                       }
+                }
+                
                 // Need to send a keepalive packet?
                 if(now - pn.lastSentPacketTime() > Node.KEEPALIVE_INTERVAL) {
                        if(logMINOR) Logger.minor(this, "Sending keepalive");


Reply via email to