Skip to content

Commit

Permalink
Resolve several possible infinite hangings because of wait() (#44)
Browse files Browse the repository at this point in the history
* Resolve several possible infinite hangings because of wait()

Basically solving the similar hanging issues as https://github.com/jenkinsci/trilead-ssh2/pull/6/files

* Update ChannelManager.java

* added support for -DChannelManager.timeout=123456
  • Loading branch information
Elisedlund-ericsson authored Jun 5, 2020
1 parent 5be986c commit abcbee1
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/com/trilead/ssh2/channel/ChannelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
public class ChannelManager implements MessageHandler
{
private static final Logger log = Logger.getLogger(ChannelManager.class);
private static final String PROPERTY_TIMEOUT = ChannelManager.class.getName() + ".timeout";
private static long DEFAULT_WAIT_TIMEOUT = Long.valueOf(System.getProperty(PROPERTY_TIMEOUT,"120000"));

private HashMap x11_magic_cookies = new HashMap();

Expand Down Expand Up @@ -107,7 +109,7 @@ private void waitUntilChannelOpen(Channel c) throws IOException
{
try
{
c.wait();
c.wait(DEFAULT_WAIT_TIMEOUT);
}
catch (InterruptedException ignore)
{
Expand Down Expand Up @@ -137,7 +139,7 @@ private final boolean waitForGlobalRequestResult() throws IOException

try
{
channels.wait();
channels.wait(DEFAULT_WAIT_TIMEOUT);
}
catch (InterruptedException ignore)
{
Expand Down Expand Up @@ -169,7 +171,7 @@ private final boolean waitForChannelRequestResult(Channel c) throws IOException

try
{
c.wait();
c.wait(DEFAULT_WAIT_TIMEOUT);
}
catch (InterruptedException ignore)
{
Expand Down Expand Up @@ -1517,7 +1519,7 @@ public void handleEndMessage(Throwable cause) throws IOException {
Channel c = (Channel) channels.elementAt(i);
synchronized (c)
{
c.eof();
c.eof();
c.state = Channel.STATE_CLOSED;
c.setReasonClosed(new IOException("The connection is being shutdown").initCause(cause));
c.closeMessageRecv = true; /*
Expand Down

0 comments on commit abcbee1

Please sign in to comment.