X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=openflow-protocol-impl%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fopenflowjava%2Fprotocol%2Fimpl%2Fcore%2Fconnection%2FOutboundQueueEntry.java;h=a97a50e9b8d1fb1e3843bfeff61b00f03c9432ff;hb=381841508961dcb1587680cdd96437b75383a13b;hp=48722dbbdd3d0db856fa83af27953b1e2dcc3e6a;hpb=be5f0cac1babcfccc7209657f2541dd0818c5cb0;p=openflowjava.git diff --git a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java index 48722dbb..a97a50e9 100644 --- a/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java +++ b/openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/core/connection/OutboundQueueEntry.java @@ -13,6 +13,7 @@ import org.opendaylight.openflowjava.protocol.api.connection.OutboundQueueExcept import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.BarrierInput; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage; import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader; +import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PacketOutInput; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -57,10 +58,18 @@ final class OutboundQueueEntry { OfHeader takeMessage() { final OfHeader ret = message; + checkCompletionNeed(); message = null; return ret; } + private void checkCompletionNeed() { + if (callback == null || PacketOutInput.class.isInstance(message)) { + completed = true; + callback = null; + } + } + boolean complete(final OfHeader response) { Preconditions.checkState(!completed, "Attempted to complete a completed message with response %s", response); @@ -77,6 +86,10 @@ final class OutboundQueueEntry { completed = reallyComplete; if (callback != null) { callback.onSuccess(response); + if (reallyComplete) { + // We will not need the callback anymore, make sure it can be GC'd + callback = null; + } } LOG.debug("Entry {} completed {} with response {}", this, completed, response); return reallyComplete; @@ -87,10 +100,10 @@ final class OutboundQueueEntry { completed = true; if (callback != null) { callback.onFailure(cause); + callback = null; } } else { LOG.warn("Ignoring failure {} for completed message", cause); } } - }