Quite often I get this error from JSch: Caught an exception, leaving main loop due to SSH_MSG_DISCONNECT: 2 Received ieof for nonexistent channel 1.
It has been reported in the mailing list already (http://sourceforge.net/mailarchive/forum.php?thread_name=201001150130.KAA18137%40jcraft.com&forum_name=jsch-users), and a fix/workaround has been suggested: add "synchronized (this)" blocks in Channel.close() and Channel.eof(): Channel.java: void close(){ synchronized (this) { if(close)return; close=true; eof_local=eof_remote=true; } .... } void eof(){ synchronized (this) { if(close)return; if(eof_local)return; eof_local=true; } .... } I tried this, but it didn't fix the problem for me. Indeed, it's still possible that 1) first thread enters eof(), checks that it's not closed yet; 2) second thread enters close(), checks conditions, and closes the channel; 3) first thread sends eof to the closed channel. To prevent this the whole eof() method body should be synchronized. This code works for me: void close(){ synchronized (this) { if(close)return; close=true; eof_local=eof_remote=true; } .... } synchronized void eof(){ if(close)return; if(eof_local)return; eof_local=true; .... } While I can use JSch built from patched sources, I'd prefer to have this fix integrated in the official JSch release. Should I file a bug to track this problem? What is the tentative release date for JSch 0.1.43? Thanks, Alexey ------------------------------------------------------------------------------ _______________________________________________ JSch-users mailing list JSch-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jsch-users