[JSch-users] JSch SFTP copy deadlock and code fix
Status: Alpha
Brought to you by:
ymnk
From: James L. <jam...@de...> - 2019-12-06 05:01:28
|
Dear Dr. Yamanaka, Thank you for JSch! While using JSch via the Apache Commons VFS API, I encountered VFS-627 <https://issues.apache.org/jira/browse/VFS-627>. I root caused the issue and found a deadlock in JSch. A patch against JSch 0.1.55 that fixes the issue is below. I also posted a detailed investigation of the problem and a simple test program to reproduce the issue at: https://github.com/jlentini/SftpCopyDeadlock I hope this fix can be included in a future version of JSch. If you would like more information or the patch in a different format, please let me know. Regards, -james James Lentini --- Prevent read/write deadlock by allocating sufficient receive buffer space diff --git a/src/main/java/com/jcraft/jsch/ChannelSftp.java b/src/main/java/com/jcraft/jsch/ChannelSftp.java index f76d1d5..3ac036f 100644 --- a/src/main/java/com/jcraft/jsch/ChannelSftp.java +++ b/src/main/java/com/jcraft/jsch/ChannelSftp.java @@ -224,7 +224,7 @@ public class ChannelSftp extends ChannelSession{ PipedOutputStream pos=new PipedOutputStream(); io.setOutputStream(pos); - PipedInputStream pis=new MyPipedInputStream(pos, rmpsize); + PipedInputStream pis=new MyPipedInputStream(pos, rq.size()*rmpsize); io.setInputStream(pis); io_in=io.in; |