Hi,

I'm seeing my SFTP server leak threads, as threads hang on
ChannelPipedInputStream.read():

"Thread-14609" prio=10 tid=0x00002b454c0a8000 nid=0x72c5 in Object.wait()
[0x00002b454a68a000]
   java.lang.Thread.State: WAITING (on object monitor)
        at java.lang.Object.wait(Native Method)
        - waiting on <0x00002b4537b5f0c8> (a
org.apache.sshd.common.util.Buffer)
        at java.lang.Object.wait(Object.java:485)
        at
org.apache.sshd.common.channel.ChannelPipedInputStream.read(ChannelPipedInputStream.java:85)
        - locked <0x00002b4537b5f0c8> (a org.apache.sshd.common.util.Buffer)
        at
org.apache.sshd.common.channel.ChannelPipedInputStream.read(ChannelPipedInputStream.java:62)
        - locked <0x00002b4537b5f0e8> (a [B)
        at java.io.DataInputStream.readInt(Unknown Source)
        at
org.apache.sshd.server.sftp.SftpSubsystem.run(SftpSubsystem.java:379)
        at java.lang.Thread.run(Unknown Source)

This is in SSHd 0.7.0 from Maven, and the wait() is here:

*synchronized* (buffer) {

            *for* (;;) {

                *if* (closed) {

                    *throw* *new* IOException("Pipe closed");

                }

                *if* (buffer.available() > 0) {

                    *break*;

                }

                *if* (writerClosed) {

                    *return* -1; // no more data to read

                }

                *try* {

                    buffer.wait();

                } *catch* (InterruptedException e) {

                    *throw* (IOException) *new*
InterruptedIOException().initCause(e);

                }

            }

            *if* (len > buffer.available()) {

                len = buffer.available();

            }

            buffer.getRawBytes(b, off, len);

            *if* (buffer.rpos() > localWindow.getPacketSize() ||
buffer.available()
== 0) {

                buffer.compact();

            }

            avail = localWindow.getMaxSize() - buffer.available();

        }

        localWindow.check(avail);

        *return* *len*;
    }


I've updated to 0.13.0 and note that
https://issues.apache.org/jira/browse/SSHD-209 saw a timeout added to this
method.

However I don't see that anything in the sshd-core source actually calls
setTimeout(). Would that be the solution? Or is there a different solution
to my hangs?

Thanks,
John

Reply via email to