You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by "Guillaume Nodet (JIRA)" <ji...@apache.org> on 2010/11/26 21:31:16 UTC
[jira] Updated: (SSHD-89) EOF is not send by the client
[ https://issues.apache.org/jira/browse/SSHD-89?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Guillaume Nodet updated SSHD-89:
--------------------------------
Summary: EOF is not send by the client (was: Client pipe)
> EOF is not send by the client
> -----------------------------
>
> Key: SSHD-89
> URL: https://issues.apache.org/jira/browse/SSHD-89
> Project: MINA SSHD
> Issue Type: Bug
> Reporter: Doron Fediuck
> Assignee: Guillaume Nodet
> Fix For: 0.6.0
>
>
> I found a case where I need to implement something of this concept:
> "gzip /tmp/sample.txt | ssh user@some.host.com gunzip -c > /tmp/sample.txt"
> I'm implementing a client that gzip's the file and send it to a remote machine
> in stdin. Here's a snip of my implementation:
> // Create the GZIP output stream
> ByteArrayOutputStream baosGZipped = new ByteArrayOutputStream ();
> GZIPOutputStream gzOut = new GZIPOutputStream(baosGZipped);
> // Open the input file
> FileInputStream src = new FileInputStream(sourceFileName);
> byte[] buf = new byte[1024];
> int len;
> while ((len = src.read(buf)) > 0) {
> gzOut.write(buf, 0, len);
> }
> src.close();
> // Complete the GZIP file
> gzOut.finish();
> gzOut.flush();
> gzOut.close();
> //create channel
> ClientChannel channel = session.createExecChannel("gunzip -c >" + destFile);
> ByteArrayInputStream in = new ByteArrayInputStream(baosGZipped.toByteArray());
> channel.setIn(in);
> ByteArrayOutputStream out = new ByteArrayOutputStream();
> channel.setOut(out);
> ByteArrayOutputStream err = new ByteArrayOutputStream();
> channel.setErr(err);
> //open channel
> channel.open();
> //wait close
> channel.waitFor(ClientChannel.CLOSED, 0);
> What I discovered is that this will never end !!!
> The problem is, that there's a pumpInputStream in ClientInputStreamPump thread (org/apache/sshd/client/channel/ChannelSession.java),
> that will never end until closeFuture.isClosed. Since this does not happen, the unzip in the remote host doesn't end, and the channel will
> never close. This prevents the client from a proper pipe implementation.
> There should be a method to properly end this while-loop thus the remote side will be able to finish and close.
> ie-
> public void CloseStream() {
> streamStop = true;
> }
> and change pumpInputStream like this:
> -while (!closeFuture.isClosed())
> +while (!closeFuture.isClosed() && !streamStop)
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.