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;
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);
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;
completed = true;
if (callback != null) {
callback.onFailure(cause);
+ callback = null;
}
} else {
LOG.warn("Ignoring failure {} for completed message", cause);
}
}
-
}