From: Robert Varga Date: Tue, 30 Apr 2019 03:12:01 +0000 (+0000) Subject: Merge changes from topic 'mri-neon-sr1' into stable/neon X-Git-Tag: release/neon-sr1~3 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=a8b245f1909fa175ab65f8d9b24d56ba2810be08;hp=3069638e99ba063fdf5df26abec397e94247f7f3;p=netconf.git Merge changes from topic 'mri-neon-sr1' into stable/neon * changes: Bump mdsal to 3.0.8 Bump yangtools to 2.1.10 Bump odlparent to 4.0.10 --- diff --git a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerWriter.java b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerWriter.java index f35372742e..e05408551f 100644 --- a/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerWriter.java +++ b/netconf/netconf-netty-util/src/main/java/org/opendaylight/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerWriter.java @@ -21,6 +21,7 @@ import org.apache.sshd.common.io.IoOutputStream; import org.apache.sshd.common.io.WritePendingException; import org.apache.sshd.common.util.buffer.Buffer; import org.apache.sshd.common.util.buffer.ByteArrayBuffer; +import org.checkerframework.checker.lock.qual.GuardedBy; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -50,6 +51,9 @@ public final class AsyncSshHandlerWriter implements AutoCloseable { this.asyncIn = asyncIn; } + @GuardedBy("asyncInLock") + private boolean isWriteExecuted = false; + public void write(final ChannelHandlerContext ctx, final Object msg, final ChannelPromise promise) { if (asyncIn == null) { @@ -67,7 +71,7 @@ public final class AsyncSshHandlerWriter implements AutoCloseable { promise.setFailure(new IllegalStateException("Channel closed")); } else { final ByteBuf byteBufMsg = (ByteBuf) msg; - if (!pending.isEmpty()) { + if (isWriteExecuted) { queueRequest(ctx, byteBufMsg, promise); return; } @@ -86,6 +90,9 @@ public final class AsyncSshHandlerWriter implements AutoCloseable { if (LOG.isTraceEnabled()) { LOG.trace("Writing request on channel: {}, message: {}", ctx.channel(), byteBufToString(byteBufMsg)); } + + isWriteExecuted = true; + asyncIn.writePacket(toBuffer(byteBufMsg)).addListener(future -> { // synchronized block due to deadlock that happens on ssh window resize // writes and pending writes would lock the underlyinch channel session @@ -133,6 +140,7 @@ public final class AsyncSshHandlerWriter implements AutoCloseable { private void writePendingIfAny() { synchronized (asyncInLock) { if (pending.peek() == null) { + isWriteExecuted = false; return; }