X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-ssh%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fssh%2Fthreads%2FHandshaker.java;h=3fffbb2d2c7b03cf6249c000d8610adb386b1bba;hp=6300c56e72d80a774891cea2409052946bfab867;hb=d0bf270d0493c04ac2e9e4a9f7de56e5b65a4ef2;hpb=45f2bf8ff9daf30ef7fbe4525366ea92a95fa213 diff --git a/opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/ssh/threads/Handshaker.java b/opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/ssh/threads/Handshaker.java index 6300c56e72..3fffbb2d2c 100644 --- a/opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/ssh/threads/Handshaker.java +++ b/opendaylight/netconf/netconf-ssh/src/main/java/org/opendaylight/controller/netconf/ssh/threads/Handshaker.java @@ -243,6 +243,12 @@ class ServerConnectionCallbackImpl implements ServerConnectionCallback { ChannelFuture clientChannelFuture = initializeNettyConnection(localAddress, bossGroup, sshClientHandler); // get channel final Channel channel = clientChannelFuture.awaitUninterruptibly().channel(); + + // write additional header before polling thread is started + // polling thread could process and forward data before additional header is written + // This will result into unexpected state: hello message without additional header and the next message with additional header + channel.writeAndFlush(Unpooled.copiedBuffer(additionalHeader.getBytes())); + new ClientInputStreamPoolingThread(session, ss.getStdout(), channel, new AutoCloseable() { @Override public void close() throws Exception { @@ -259,9 +265,6 @@ class ServerConnectionCallbackImpl implements ServerConnectionCallback { } } }, sshClientHandler.getChannelHandlerContext()).start(); - - // write additional header - channel.writeAndFlush(Unpooled.copiedBuffer(additionalHeader.getBytes())); } else { logger.debug("{} Wrong subsystem requested:'{}', closing ssh session", serverSession, subsystem); String reason = "Only netconf subsystem is supported, requested:" + subsystem;