[ https://issues.apache.org/jira/browse/SSHD-812?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16416766#comment-16416766 ]
Goldstein Lyor commented on SSHD-812: ------------------------------------- The way to do this would be: {code:java} @Override public void start(Environment env) throws IOException { this.env = env; try { ExecutorService executor = getExecutorService(); ====> start several threads here <==== pendingFuture = executor.submit(this); } catch (RuntimeException e) { // e.g., RejectedExecutionException log.error("Failed (" + e.getClass().getSimpleName() + ") to start command: " + e.toString(), e); throw new IOException(e); } } {code} and then modify the _run()_ method so that all threads somehow wait on some lock to read a command packet. Once read, the thread that succeeded relinquishes the lock (thus letting some other thread read a packet), processes the request and then goes back to waiting to its turn to read again. The code {{SftpSubsystem}} code though now not only has to be *multi-thread safe*, but also raises some *race conditions*: * What if the session is closed while a thread is processing a request but has not generated a response * What if a file handle is closed by a command from one thread while another thread is reading/writing to it * Ditto for files being removed, renamed, symlink-ed, concurrently etc... One could say it is the client's problem, but we need to make the server able to tolerate such behavior > support asynchronization mode for sftp subsystem > ------------------------------------------------ > > Key: SSHD-812 > URL: https://issues.apache.org/jira/browse/SSHD-812 > Project: MINA SSHD > Issue Type: New Feature > Affects Versions: 1.7.0 > Environment: java1.8, linux > Reporter: Zhenliang Su > Assignee: Goldstein Lyor > Priority: Minor > Labels: asynchronous, sftp > Attachments: Main.java, doRead.png > > > I used SSHD as a middleman between client and target sftp server. > I found that, when filezilla client directly connect to the target sftp > server, it transfers fast. When filezilla client connect to the middleman, it > transfers slow. > I analyzed the source code of > org.apache.sshd.server.subsystem.sftp.SftpSubsystem#doRead, and I found it > behaves like block mode, and client's other SSH_FXP_READ request blocked in > the same thread. > > my middleman code: > [^Main.java] > -- This message was sent by Atlassian JIRA (v7.6.3#76005)