X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-netty-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fnettyutil%2Fhandler%2Fssh%2Fclient%2FAsyncSshHandlerWriter.java;h=10941021bceaa1e12433ff5291e7d55741ad822a;hp=757dc1a2ba334d4169718e751a553d309e6240f6;hb=63bf2c78aab8a4a48201877a5b5de255ff3cdf75;hpb=be4649e2eb2eb48970107d50e0da9e54428dd846 diff --git a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerWriter.java b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerWriter.java index 757dc1a2ba..10941021bc 100644 --- a/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerWriter.java +++ b/opendaylight/netconf/netconf-netty-util/src/main/java/org/opendaylight/controller/netconf/nettyutil/handler/ssh/client/AsyncSshHandlerWriter.java @@ -68,7 +68,7 @@ public final class AsyncSshHandlerWriter implements AutoCloseable { //sending message with pending //if resending message not succesfull, then attribute wasPending is true - private void writeWithPendingDetection(final ChannelHandlerContext ctx, final ChannelPromise promise, final ByteBuf byteBufMsg, boolean wasPending) { + private void writeWithPendingDetection(final ChannelHandlerContext ctx, final ChannelPromise promise, final ByteBuf byteBufMsg, final boolean wasPending) { try { if (LOG.isTraceEnabled()) { @@ -80,7 +80,7 @@ public final class AsyncSshHandlerWriter implements AutoCloseable { public void operationComplete(final IoWriteFuture future) { if (LOG.isTraceEnabled()) { LOG.trace("Ssh write request finished on channel: {} with result: {}: and ex:{}, message: {}", - ctx.channel(), future.isWritten(), future.getException(), byteBufToString(byteBufMsg)); + ctx.channel(), future.isWritten(), future.getException(), byteBufToString(byteBufMsg)); } // Notify success or failure @@ -94,6 +94,14 @@ public final class AsyncSshHandlerWriter implements AutoCloseable { // Not needed anymore, release byteBufMsg.release(); + synchronized (AsyncSshHandlerWriter.this) { + //rescheduling message from queue after successfully sent + if (wasPending) { + byteBufMsg.resetReaderIndex(); + pending.remove(); + } + } + // Check pending queue and schedule next // At this time we are guaranteed that we are not in pending state anymore so the next request should succeed writePendingIfAny(); @@ -101,12 +109,6 @@ public final class AsyncSshHandlerWriter implements AutoCloseable { } }); - //rescheduling message from queue after successfully sent - if(wasPending){ - byteBufMsg.resetReaderIndex(); - pending.remove(); - } - } catch (final WritePendingException e) { if(wasPending == false){