Commit 2923b46d authored by Guus der Kinderen's avatar Guus der Kinderen Committed by akrherz

OF-1324: Queue that holds outbound data pending s2s session should be bounded.

This commit adds an upper-limit to the amount of stanzas that can be queued in an outgoing
session promise. Any data that won't fit in the queue is rejected immediately. Note that
this can lead to a situation where later stanzas are rejected before stanzas that or sent
earlier (but got in the queue).
parent f262e973
......@@ -25,11 +25,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.*;
import java.util.concurrent.locks.Lock;
import org.jivesoftware.openfire.RoutableChannelHandler;
......@@ -203,7 +199,8 @@ public class OutgoingSessionPromise implements RoutableChannelHandler {
private OutgoingSessionPromise promise;
private String domain;
private Queue<Packet> packetQueue = new ConcurrentLinkedQueue<>();
private Queue<Packet> packetQueue = new ArrayBlockingQueue<>( JiveGlobals.getIntProperty(ConnectionSettings.Server.QUEUE_SIZE, 50) );
/**
* Keep track of the last time s2s failed. Once a packet failed to be sent to a
* remote server this stamp will be used so that for the next 5 seconds future packets
......@@ -338,8 +335,13 @@ public class OutgoingSessionPromise implements RoutableChannelHandler {
}
}
public void addPacket(Packet packet) {
packetQueue.add(packet);
public void addPacket(Packet packet)
{
if ( !packetQueue.offer( packet ) )
{
returnErrorToSender(packet);
Log.debug( "OutgoingSessionPromise: Error sending packet to remote server (queue full): " + packet);
}
}
public String getDomain() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment