From 6a499f9932f6965ce84e97e98d2cd188482e8327 Mon Sep 17 00:00:00 2001 From: Michal Polkorab Date: Mon, 11 Jan 2016 22:28:52 +0100 Subject: [PATCH] Bug 4942 - Barrier send condition updated - fixes uncovered case - if a barrier was scheduled and another barrier was sent due to exceeded "maxNonBarrierMessages", then we would cancel / not enqueue the scheduled barrier because of "sinceLast" time - this time is lower than "maxBarrierNanos" Change-Id: I86f1be2ac0dc76241523ee3b6e6bf12bec90889e Signed-off-by: Michal Polkorab (cherry picked from commit 62c0db21eb5d45415011647427ba9f7a0dc69302) --- .../core/connection/OutboundQueueManager.java | 15 +++++---------- .../core/connection/StackedOutboundQueue.java | 16 ++++++++++++++-- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java index 90db23da..1769face 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueManager.java @@ -86,16 +86,11 @@ final class OutboundQueueManager extends return; } - final long now = System.nanoTime(); - final long sinceLast = now - lastBarrierNanos; - if (sinceLast >= maxBarrierNanos) { - LOG.debug("Last barrier at {} now {}, elapsed {}", lastBarrierNanos, now, sinceLast); - // FIXME: we should be tracking requests/responses instead of this - if (nonBarrierMessages == 0) { - LOG.trace("No messages written since last barrier, not issuing one"); - } else { - scheduleBarrierMessage(); - } + if (currentQueue.isBarrierNeeded()) { + LOG.trace("Sending a barrier message"); + scheduleBarrierMessage(); + } else { + LOG.trace("Barrier not needed, not issuing one"); } } diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java index a9876d99..cafd114c 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/StackedOutboundQueue.java @@ -51,12 +51,24 @@ final class StackedOutboundQueue extends AbstractStackedOutboundQueue { } Long reserveBarrierIfNeeded() { + if (isBarrierNeeded()) { + return reserveEntry(); + } + return null; + } + + /** + * Checks if Barrier Request is the last message enqueued. If not, one needs + * to be scheduled in order to collect data about previous messages. + * @return true if last enqueued message is Barrier Request, false otherwise + */ + boolean isBarrierNeeded() { final long bXid = barrierXid; final long fXid = firstSegment.getBaseXid() + flushOffset; if (bXid >= fXid) { LOG.debug("Barrier found at XID {} (currently at {})", bXid, fXid); - return null; + return false; } - return reserveEntry(); + return true; } } -- 2.36.6