Hi ymnk,
I forwarded a port to a web server. Through that port I attempted to
download and run a Web Start Application via JNLP. It is a large and
complex Application (70MB and over 80 files). My Session would
spuriously shut down during the download of the Application, yet no
error was thrown. This occurred repeatedly.
After I uncommented the "e.printStackTrace();" line in the main Session
loop, it printed the Exception: "Received data for nonexistent channel".
I see that you made some patches in 0.1.43 to address this problem
(|bugfix: data may be written to the closed channel. FIXED.|), but it
was still happening to me. I made additional changes similar to yours,
and it resolved my problems. Here is the patch diff to 0.1.45:
==== BEGIN PATCH =====
Index: src/main/java/com/jcraft/jsch/Channel.java
===================================================================
--- src/main/java/com/jcraft/jsch/Channel.java (revision 253)
+++ src/main/java/com/jcraft/jsch/Channel.java (working copy)
@@ -338,7 +338,10 @@
try{
int foo=dataLen;
dataLen=0;
- getSession().write(packet, channel, foo);
+ synchronized(this){
+ if(!close)
+ getSession().write(packet, channel, foo);
+ }
}
catch(Exception e){
close();
Index: src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java
===================================================================
--- src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java (revision 253)
+++ src/main/java/com/jcraft/jsch/ChannelDirectTCPIP.java (working copy)
@@ -165,13 +165,16 @@
eof();
break;
}
- if(close)break;
+ //if(close)break;
packet.reset();
buf.putByte((byte)Session.SSH_MSG_CHANNEL_DATA);
buf.putInt(recipient);
buf.putInt(i);
buf.skip(i);
- _session.write(packet, this, i);
+ synchronized(this){
+ if(close)break;
+ _session.write(packet, this, i);
+ }
}
}
catch(Exception e){
Index: src/main/java/com/jcraft/jsch/ChannelForwardedTCPIP.java
===================================================================
--- src/main/java/com/jcraft/jsch/ChannelForwardedTCPIP.java
(revision 253)
+++ src/main/java/com/jcraft/jsch/ChannelForwardedTCPIP.java (working
copy)
@@ -110,12 +110,15 @@
break;
}
packet.reset();
- if(close)break;
+ //if(close)break;
buf.putByte((byte)Session.SSH_MSG_CHANNEL_DATA);
buf.putInt(recipient);
buf.putInt(i);
buf.skip(i);
- getSession().write(packet, this, i);
+ synchronized(this){
+ if(close)break;
+ getSession().write(packet, this, i);
+ }
}
}
catch(Exception e){
Index: src/main/java/com/jcraft/jsch/Session.java
===================================================================
--- src/main/java/com/jcraft/jsch/Session.java (revision 253)
+++ src/main/java/com/jcraft/jsch/Session.java (working copy)
@@ -1212,7 +1212,8 @@
//}
}
}
- _write(packet);
+ if(!c.close)
+ _write(packet);
}
public void write(Packet packet) throws Exception{
@@ -1339,7 +1340,10 @@
buf.putByte((byte)SSH_MSG_CHANNEL_WINDOW_ADJUST);
buf.putInt(channel.getRecipient());
buf.putInt(channel.lwsize_max-channel.lwsize);
- write(packet);
+ synchronized(channel){
+ if(!channel.close && !channel.eof_remote)
+ write(packet);
+ }
channel.setLocalWindowSize(channel.lwsize_max);
}
break;
@@ -1369,7 +1373,10 @@
buf.putByte((byte)SSH_MSG_CHANNEL_WINDOW_ADJUST);
buf.putInt(channel.getRecipient());
buf.putInt(channel.lwsize_max-channel.lwsize);
- write(packet);
+ synchronized(channel){
+ if(!channel.close && !channel.eof_remote)
+ write(packet);
+ }
channel.setLocalWindowSize(channel.lwsize_max);
}
break;
@@ -1551,14 +1558,15 @@
}
}
}
- catch(Exception e){
+ catch(Throwable e){
in_kex=false;
if(JSch.getLogger().isEnabled(Logger.INFO)){
JSch.getLogger().log(Logger.INFO,
"Caught an exception, leaving main loop
due to " + e.getMessage());
}
//System.err.println("# Session.run");
- //e.printStackTrace();
+ if(e instanceof JSchException)
+ e.printStackTrace();
}
try{
disconnect();
===== END PATCH =====
------------------------------------------------------------------------------
Ridiculously easy VDI. With Citrix VDI-in-a-Box, you don't need a complex
infrastructure or vast IT resources to deliver seamless, secure access to
virtual desktops. With this all-in-one solution, easily deploy virtual
desktops for less than the cost of PCs and save 60% on VDI infrastructure
costs. Try it free! http://p.sf.net/sfu/Citrix-VDIinabox
_______________________________________________
JSch-users mailing list
JSch-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jsch-users