From 3355481bf8dcac1619c097d7db3d9faa687c8978 Mon Sep 17 00:00:00 2001 From: boris Date: Mon, 30 Mar 2015 10:49:39 +0000 Subject: [PATCH] Drop the first packet instead of the last. --- src/org/ice4j/ice/harvest/SinglePortUdpHarvester.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/org/ice4j/ice/harvest/SinglePortUdpHarvester.java b/src/org/ice4j/ice/harvest/SinglePortUdpHarvester.java index b395f35..78200c0 100644 --- a/src/org/ice4j/ice/harvest/SinglePortUdpHarvester.java +++ b/src/org/ice4j/ice/harvest/SinglePortUdpHarvester.java @@ -459,9 +459,14 @@ public class SinglePortUdpHarvester { synchronized (queue) { - // XXX Should we drop the first packet from the queue instead? - if (!queue.offer(buf)) + // Drop the first rather than the current packet, so that + // receivers can notice the loss earlier. + if (queue.size() == QUEUE_SIZE) + { logger.info("Dropping a packet because the queue is full."); + queue.poll(); + } + queue.offer(buf); queue.notifyAll(); }