On Fri, Nov 14, 2008 at 7:39 AM, <toad at freenetproject.org> wrote:
> Author: toad
> Date: 2008-11-13 23:39:17 +0000 (Thu, 13 Nov 2008)
> New Revision: 23542
>
> Modified:
> trunk/freenet/src/freenet/node/FNPPacketMangler.java
> trunk/freenet/src/freenet/node/OutgoingPacketMangler.java
> trunk/freenet/src/freenet/node/PeerNode.java
> Log:
> Send a packet even if we get a WouldBlockException...
>
>
> Modified: trunk/freenet/src/freenet/node/FNPPacketMangler.java
> ===================================================================
> --- trunk/freenet/src/freenet/node/FNPPacketMangler.java 2008-11-13
> 20:02:47 UTC (rev 23541)
> +++ trunk/freenet/src/freenet/node/FNPPacketMangler.java 2008-11-13
> 23:39:17 UTC (rev 23542)
> @@ -2007,7 +2007,7 @@
> /* (non-Javadoc)
> * @see
> freenet.node.OutgoingPacketMangler#processOutgoingOrRequeue(freenet.node.MessageItem[],
> freenet.node.PeerNode, boolean, boolean)
> */
> - public void processOutgoingOrRequeue(MessageItem[] messages, PeerNode
> pn, boolean neverWaitForPacketNumber, boolean dontRequeue, boolean onePacket)
> {
> + public boolean processOutgoingOrRequeue(MessageItem[] messages,
> PeerNode pn, boolean neverWaitForPacketNumber, boolean dontRequeue, boolean
> onePacket) {
> String requeueLogString = "";
> if(!dontRequeue) {
> requeueLogString = ", requeueing";
>
> Modified: trunk/freenet/src/freenet/node/OutgoingPacketMangler.java
> ===================================================================
> --- trunk/freenet/src/freenet/node/OutgoingPacketMangler.java 2008-11-13
> 20:02:47 UTC (rev 23541)
> +++ trunk/freenet/src/freenet/node/OutgoingPacketMangler.java 2008-11-13
> 23:39:17 UTC (rev 23542)
> @@ -26,8 +26,9 @@
> * Any packets which cannot be sent will be requeued on the PeerNode.
> * @param onePacketOnly If true, we will only send one packet, and
> will requeue any
> * messages that don't fit in that single packet.
> + * @return True if we sent a packet.
> */
> - public void processOutgoingOrRequeue(MessageItem[] messages, PeerNode
> pn,
> + public boolean processOutgoingOrRequeue(MessageItem[] messages,
> PeerNode pn,
> boolean neverWaitForPacketNumber, boolean dontRequeue,
> boolean onePacketOnly);
>
> /**
>
> Modified: trunk/freenet/src/freenet/node/PeerNode.java
> ===================================================================
> --- trunk/freenet/src/freenet/node/PeerNode.java 2008-11-13 20:02:47
> UTC (rev 23541)
> +++ trunk/freenet/src/freenet/node/PeerNode.java 2008-11-13 23:39:17
> UTC (rev 23542)
> @@ -2407,7 +2407,7 @@
> * @throws PacketSequenceException If there is an error sending the
> packet
> * caused by a sequence inconsistency.
> */
> - public boolean sendAnyUrgentNotifications(boolean forceSendPrimary)
> throws PacketSequenceException {
> + public boolean sendAnyUrgentNotifications(boolean forceSendPrimary) {
> boolean sent = false;
> if(logMINOR)
> Logger.minor(this, "sendAnyUrgentNotifications");
> @@ -2433,6 +2433,8 @@
> // Ignore
> } catch(WouldBlockException e) {
> // Impossible, ignore
> + } catch(PacketSequenceException e) {
> + // Impossible, ignore
better log the impossible error
> }
> }
> }
> @@ -2451,6 +2453,8 @@
> // Ignore
> } catch(WouldBlockException e) {
> Logger.error(this, "Impossible: " + e,
> e);
> + } catch(PacketSequenceException e) {
> + // Impossible, ignore
same here
> }
> }
> return sent;
> @@ -4014,10 +4018,12 @@
> public boolean maybeSendPacket(long now, Vector<ResendPacketItem>
> rpiTemp, int[] rpiIntTemp) {
> // If there are any urgent notifications, we must send a
> packet.
> boolean mustSend = false;
> + boolean mustSendPacket = false;
> if(mustSendNotificationsNow(now)) {
> if(logMINOR)
> Logger.minor(this, "Sending notification");
> mustSend = true;
> + mustSendPacket = true;
> }
> // Any packets to resend? If so, resend ONE packet and then
> return.
> for(int j = 0; j < 2; j++) {
> @@ -4074,6 +4080,7 @@
> Logger.minor(this, "Sending keepalive");
> keepalive = true;
> mustSend = true;
> + mustSendPacket = true;
> }
>
> ArrayList<MessageItem> messages = new
> ArrayList<MessageItem>(10);
> @@ -4122,17 +4129,17 @@
> // Send packets, right now, blocking, including any
> active notifications
> // Note that processOutgoingOrRequeue will drop
> messages from the end
> // if necessary to fit the messages into a single
> packet.
> -
> getOutgoingMangler().processOutgoingOrRequeue(messages.toArray(new
> MessageItem[messages.size()]), this, true, false, true);
> +
> if(!getOutgoingMangler().processOutgoingOrRequeue(messages.toArray(new
> MessageItem[messages.size()]), this, true, false, true)) {
> + if(mustSendPacket) {
> + if(!sendAnyUrgentNotifications(false))
> +
> sendAnyUrgentNotifications(true);
> + }
> + }
> return true;
> } else {
> if(mustSend) {
> - try {
> if(sendAnyUrgentNotifications(false))
> return true;
> - } catch (PacketSequenceException e) {
> - Logger.error(this, "Caught "+e, e);
> - return false;
> - }
> // Can happen occasionally as a race
> condition...
> Logger.normal(this, "No notifications sent
> despite no messages and mustSend=true for "+this);
> }
>
> _______________________________________________
> cvs mailing list
> cvs at freenetproject.org
> http://emu.freenetproject.org/cgi-bin/mailman/listinfo/cvs
>