tomaswolf opened a new issue, #266:
URL: https://github.com/apache/mina-sshd/issues/266

   The ultimate problem is a general one concerning ChannelExecs:
   
   If
   * there is a communication protocol implemented between the client and the 
remote command via the stdin/stdout streams,
   * and if the protocol is such that the remote command can return an error 
code _in this application protocol_,
   * and the client uses the default inverted output stream to read that error 
code,
   * and the client then decides to close the channel (even gracefully),
   
   then it is possible that the `AbstractClientChannel`'s `out` stream is 
closed between lines 
[436](https://github.com/apache/mina-sshd/blob/a85d0743/sshd-core/src/main/java/org/apache/sshd/client/channel/AbstractClientChannel.java#L436)
 and 437, and then the `flush()`call on the `ChannelPipedOutputStream` may 
fail, causing the whole session to go down.
   
   This can happen in the `ScpTest`at line 
[343](https://github.com/apache/mina-sshd/blob/a85d0743e/sshd-scp/src/test/java/org/apache/sshd/scp/client/ScpTest.java#L343),
 which tests an scp upload command that should fail. The scp server sends back 
an ERROR ack, which the client reads (on an I/O thread) and forwards in 
`AbstractClientChannel`. The client reads this though the 
`ChannelPipedInputStream` (on the main thread) and throws an exception, which 
then causes the channel to be closed at the end of 
`DefaultScpClient.runUpload()` (still on the main thread). Only then does the 
I/O thread call `flush()`, which then fails with an exception.
   
   So in short we have
   
   1. I/O thread: receive data
   2. I/O thread: write data to `ChannelPipedOutputStream`
   3. Main thread: read data from `ChannelPipedInputStream`
   4. Main thread: close channel
   5. I/O thread: call `ChannelPipedOutputStream.flush()` and fail.
   
   This is all the more infuriating since `ChannelPipedOutputStream.flush()` is 
essentially a no-op. Moreover: an exception when a channel has received data 
and tries to forward it should not take down the whole session but only this 
channel.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@mina.apache.org
For additional commands, e-mail: dev-h...@mina.apache.org

Reply via email to