mina-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Lecharny <elecha...@gmail.com>
Subject Re: Client pipe problem (bug)
Date Tue, 01 Jun 2010 08:22:54 GMT
On 6/1/10 10:14 AM, Doron Fediuck wrote:
> On Sunday 30 May 2010 10:04:37 Doron Fediuck wrote:
>    
>> Hi !
>> I'm implementing some basic client functionality using sshd client.
>> 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"
>>
>> On my implementation the code (using sshd client) is running an exec channel
>> of the gzip command into stdout. Then I should be able to use the stdout stream
>> and use it to unzip the file locally.
>>
>> 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 thread in (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.
>> Can you please open a bug for this issue ?
>>
>> Thanks !
>> Doron.
>>
>>      
> Anyone ?
>    
Can you open a JIRA ? Sounds like a bug... (see 
http://mina.apache.org/issue-tracking.html)`


Thanks !


-- 
Regards,
Cordialement,
Emmanuel L├ęcharny
www.nextury.com



Mime
View raw message